is Sd Card Writable - Android android.os

Android examples for android.os:SD Card

Description

is Sd Card Writable

Demo Code

import android.content.ContextWrapper;
import android.os.Environment;
import java.io.File;

public class Main{


    public static boolean isSdCardWritable() {
        String lStorageState = Environment.getExternalStorageState();
        boolean lIsSdcardWritable;
        boolean lIsSdCardAvailable;

        if (Environment.MEDIA_MOUNTED.equals(lStorageState)) {
            lIsSdCardAvailable = lIsSdcardWritable = true;
        } else if (Environment.MEDIA_MOUNTED_READ_ONLY
                .equals(lStorageState)) {
            lIsSdCardAvailable = true;/*from   w  w w.j  a  v a  2  s  . c o m*/
            lIsSdcardWritable = false;
        } else {
            lIsSdCardAvailable = lIsSdcardWritable = false;
        }
        return lIsSdCardAvailable && lIsSdcardWritable;
    }

}

Related Tutorials