Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Checks if storage is available for our use.
- *
- * @return true if storage is available and writeable
- */
- public static boolean isStorageAvailable() {
- boolean mExternalStorageAvailable;
- boolean mExternalStorageWriteable;
- 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;
- }
- Ln.i(mExternalStorageAvailable ? "Storage available" : "Storage Unavailable");
- Ln.i(mExternalStorageWriteable ? "Storage writeable" : "Storage not writeable");
- return (mExternalStorageAvailable && mExternalStorageWriteable);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement