1

I have a problem with android emulator. I need to choose a file from sdcard e send it to a WS. The running emulator is a Nexus 5 with android 6. I've searched everyehere, but none of the solution works. I use this code to open a file explorer:

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.setType("file/*");
            startActivity(intent);

but when I run the code, I can't find the file on the sdcard. I put the files with adb istructions and in the File Explorer of Android Device Monitor I can see the files. Farther, iI can see the picture if I search in the Gallery of the emulator. Which is the problem? Where is my error? I tried also Dev Tool>Media Provider

mary
  • 83
  • 2
  • 8

1 Answers1

0

Add the following permission in the manifest

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Stef_ro89
  • 81
  • 1
  • 10
  • I have added the permission and now I can see the file but I can't select it. The file is locked and the permission for the file is: -rwxrwx---, I need to change it? – mary Jun 24 '16 at 11:12
  • you can try to replace the READ with WRITE permission but I don't think it will do anything. Try to look at this: http://stackoverflow.com/questions/26744842/how-to-use-the-new-sd-card-access-api-presented-for-lollipop – Stef_ro89 Jun 29 '16 at 11:57
  • If I use Intent.ACTION_OPEN_DOCUMENT_TREE, I have a warning and I can't pick the path of th file because I can access to the directory but not to the full path of the file. If I use ACTION_GET_CONTENT I'm unable to select the file, I can see it but I can't select it. I need to open the file explorer, select the file and return to my activity and pick the full path of the file. How I can reach this? – mary Jul 03 '16 at 16:56