1

Through my application the user can choose a file from the filemanager and process the choosen file ( Example: A PDF document ) for other steps like printing or to email.

To do this I used the below code to display the intent, from which the user can choose a file from file-manager option.

protected void showFileChooser(String title, String type) {
        Log.i(TAG, "FileChooserActivity showFileChooser(title,type)");

        if (TextUtils.isEmpty(title)) title = getString(R.string.select_file);      
        if (TextUtils.isEmpty(type)) type = "*/*";  

        // Implicitly allow the user to select a particular kind of data
        final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 

        // Specify the MIME data type filter (Must be lower case)
        intent.setType(type.toLowerCase()); 

        // Only return URIs that can be opened with ContentResolver
        intent.addCategory(Intent.CATEGORY_OPENABLE);

        // Display intent chooser
        try {
            startActivityForResult(
                    Intent.createChooser(intent, title),6384);
        } catch (android.content.ActivityNotFoundException e) {

            Log.i(TAG,"FileChooserActivity showFileChooser(title,type) Exception" +Log.getStackTraceString(e));
            onFileError(e);
        }
    }

Problem in Android Kitkat version ( 4.4 ) :

Using the above code , I can access all files from the file manager ( i.e., both sub folder's and root folder) in android 4.3 and all android versions except Android 4.4.

In Android 4.4 , I can access files from the root folder, where as I cant access the files from the subfolders. I get java.io.FileNotFoundException as exception.

Note: I installed Astro File Manager and through this I can access both root and sub-folders in Android 4.4. But I cant access the sub-folder files through Androids default file manager.

2vision2
  • 4,933
  • 16
  • 83
  • 164
  • 3
    Since there is no "default file manager" in Android, you will need to contact the developers of that application. – CommonsWare Jun 05 '14 at 12:24
  • This link might help: https://developer.android.com/about/versions/android-4.4.html – Phantômaxx Jun 05 '14 at 12:28
  • @CommonsWare I get this error in "Asus- Nexus 7" tablet mobile. So do you mean Moto-G has developed a seperate file manager or how can I contact the particular Filemanager developer? – 2vision2 Jun 05 '14 at 12:47
  • 1
    "I get this error in "Asus- Nexus 7" tablet mobile" -- there is no file manager installed by default on a Nexus 7. – CommonsWare Jun 05 '14 at 12:52
  • As has already been explained, "Android" does not ship with a file manager. If you need particular behavior, tell the user to install a particular 3rd party file manager or include the functionality in your application - don't depend on what vendors may randomly add to some devices and not others. – Chris Stratton Jun 05 '14 at 14:56

0 Answers0