Max Max - 1 year ago 98
Android Question

Write permission for external sd card in android 4.0

I am facing a problem while trying to write a files into External SD Card in

android 4.0.3
,even I have made use of the write permissions like
, So I have found another way to work on it, but now I want to find out whether my app is possible to write into the Removable SD Card
or not, if not then I would like to switch to Internal SD Card.

So now the question is how will I come to know whether writing into Removable SD Card supported or not, So if anyone has done any similar kind of an implementation please feel free to share the code here.

Answer Source

Answer directly from the API guide:

    boolean mExternalStorageAvailable = false;
    boolean mExternalStorageWriteable = false;
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        mExternalStorageAvailable = mExternalStorageWriteable = true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        mExternalStorageAvailable = true;
        mExternalStorageWriteable = false;
    } else {
        // Something else is wrong. It may be one of many other states, but all we need
        //  to know is we can neither read nor write
        mExternalStorageAvailable = mExternalStorageWriteable = false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download