Skip to content

Instantly share code, notes, and snippets.

@behroozAlborzi
Created July 4, 2021 17:15
Show Gist options
  • Save behroozAlborzi/bde8f4007758295133ab35c50e592e67 to your computer and use it in GitHub Desktop.
Save behroozAlborzi/bde8f4007758295133ab35c50e592e67 to your computer and use it in GitHub Desktop.
import android.os.Environment;
public class StorageHelper {
public static boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
/* Checks if external storage is available to at least read */
public static boolean isExternalStorageReadable() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state) ||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment