Write application data to a private directory on SDK and Android 4.4 and higher

There are many questions on this topic, but I can not find the answers to my corrective examples.

I use Samsung Galaxy S5 to run Android 4.4, which is limited for storage

The white paper says:

The WRITE_EXTERNAL_STORAGE permission should only provide write access to the primary external storage on the device. Applications are not allowed to write to external external storage devices, with the exception of their directories specific to the package, as allowed by synthesized permissions. Limiting recording in this way ensures that the system can clean up files when applications are uninstalled.

My application should write files to Sdcard (Absolute path is /storage/extSdCard ), so I write my application data to the directory of my application: /storage/extSdCard/Android/com.myapp.example/files , but received an exception that was excluded from permission . Therefore, I suspect the following statement:

excluding their directories specific directories allowed by synthesized permissions

I think that I can not write to the root directory /storage/extSdCard , but still I can write the data of my application to the directory of my application. Am I misunderstood something?

p / s: I can still write my application data to the built-in storage: /storage/emulated/0/Android/data/com.myapp.example/files . I do not want to use getExternalFileDirs() because it always returns the built-in, not my sdcard directory.

0
android
Oct 06 '15 at 4:00
source share
2 answers

If getExternalFilesDir (null) returns somewhere else in /storage/extSdCard/Android/com.myapp.example/files, then I would think that is why it gives you access errors. The only place on the SD card that you can write without permission is the directory returned by getExternalFilesDir ()

Since you are saying that the directory returned by getExternalFilesDir (null) is not acceptable, I would suggest adding the permission WRITE_EXTERNAL_STORAGE to your manifest.

+1
Oct 06 '15 at 4:26
source share

The specific directory for your application should be /storage/extSdCard/Android/data/com.myapp.example/files , not /storage/extSdCard/Android/com.myapp.example/files

+1
Oct 07 '15 at 10:36
source share



All Articles