Android examples for android.os:Disk
has writable Storage
import java.io.File; import android.os.Environment; public class Main { private static final String TAG = ""; static public boolean hasStorage(boolean requireWriteAccess) { String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { if (requireWriteAccess) { boolean writable = checkFsWritable(); return writable; } else {/*w ww. j a v a2 s . com*/ return true; } } else if (!requireWriteAccess && Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { return true; } return false; } private static boolean checkFsWritable() { String directoryName = Environment.getExternalStorageDirectory().toString() + "/DCIM"; File directory = new File(directoryName); if (!directory.isDirectory()) { if (!directory.mkdirs()) { return false; } } return directory.canWrite(); } }