A
A
Artyom2016-03-17 18:04:22
Java
Artyom, 2016-03-17 18:04:22

How to access sd card on android?

How to access the removable sd card on android 4.4 and higher?
It is necessary to add the ability to transfer some application data to an external card from the application itself. (in code).

Log.d(TAG, "" + Environment.getExternalStorageDirectory());
Log.d(TAG, "" + this.getApplicationContext().getExternalFilesDirs(null));
Log.d(TAG, "" + this.getApplicationContext().getExternalFilesDir(null));

Returns accordingly
/storage/sdcard0
/storage/sdcard0/Android/data/com.package/files (single element array)
/storage/sdcard0/Android/data/com.package/files

But this is the phone's memory (external).
Before android 4.4 there is at least:
String strSDCardPath = System.getenv("SECONDARY_STORAGE");

which, although not always, returns the path to the SD card. On versions higher than 4.4, it no longer works, respectively.
Permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.STORAGE" />

Device ZTE Blade L3.
I don't know where to look or where to look. And is it even real? Other applications somehow save.
And if not, then you can read some official docks on this topic?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question