Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public class StorageChecker {
  2. public static void checkStorageAvailability(Context context){
  3. boolean isStorageExist = false;
  4. boolean isStorageWritable = false;
  5.  
  6. String state = Environment.getExternalStorageState();
  7.  
  8. if (Environment.MEDIA_MOUNTED.equals(state)){
  9. isStorageExist = isStorageWritable = true;
  10. } else if(Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)){
  11. isStorageExist = true;
  12. isStorageWritable = false;
  13. Toast.makeText(context, "Storage is read only", Toast.LENGTH_SHORT).show();
  14. } else {
  15. isStorageExist = isStorageWritable = false;
  16. Toast.makeText(context, "Storage is not exist", Toast.LENGTH_SHORT).show();
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement