0
votes

I have placed a file at /sdcard/Download/settings.json on an Android Virtual Device. I've verified the existence of this file use the Device File Explorer as well as through ADB.

However, when I try to open/read this file I get the following error: java.io.FileNotFoundException: /sdcard/Download/settings.json (Permission denied)

I've put the following into the AndroidManifest.xml file:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

A screenshot of the debug process is below:

enter image description here

Here is the view of the Device File Explorer:

enter image description here

And here is the proof the file exists using ADB:

generic_x86:/sdcard/Download $ ls -lah
total 16K
drwxrwx--x  2 root sdcard_rw 4.0K 2019-09-10 11:17 .
drwxrwx--x 13 root sdcard_rw 4.0K 2019-09-03 14:13 ..
-rw-rw----  1 root sdcard_rw  24K 2019-09-09 14:41 settings.json
generic_x86:/sdcard/Download $                             
  • What do I need to do to be able to open/read this file on an Android Virtual Device?
  • Do I somehow have to change the permissions on the file? I've tried chmod but it doesn't affect the file permissions.
1
Have you requested runtime permissions to access external storage?Gabe Sechan
@GabeSechan I did. I added <uses-permission> in the manifest file.Chimera
that isn't run time. For modern androids, you need manifest level AND runtime permissionsGabe Sechan
@GabeSechan Thank you! How do I add runtime permissions? I suppose google android runtime permissions? :-)Chimera

1 Answers

0
votes

what is the version of Android Virtual Device?