1.It returns true if the external storage is available else false otherwise
.
/**
* Check if external storage available
* @return
*/
public static boolean isExternalStorageAvailable() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
return true;
}
return false;
}
2.
It returns true if the external storage is read only else false otherwise
/**
* Check if external storage is read only
* @return
*/
public static boolean isExternalStorageReadOnly() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {
return true;
}
return false;
}
3.
It returns true if the external storage is writable else false otherwise
/**
* @return True if the external storage is writable.
* False otherwise.
*/
public static boolean
String state = Environment.getExternalStorageState();
// Check if writable
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
* @return True if the external storage is writable.
* False otherwise.
*/
public static boolean
isExternalStorage
writeonly() {String state = Environment.getExternalStorageState();
// Check if writable
if (Environment.MEDIA_MOUNTED.equals(state)) {
return true;
}
return false;
}
No comments:
Post a Comment