Guest User

Untitled

a guest
Nov 15th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
  2. double sdAvailSize = (double)stat.getAvailableBlocks()
  3. * (double)stat.getBlockSize();
  4. //One binary gigabyte equals 1,073,741,824 bytes.
  5. double gigaAvailable = sdAvailSize / 1073741824;
  6.  
  7. File dir = new File(Environment.getExternalStorageDirectory().getParent());
  8. File[] f = dir.listFiles();
  9. for(File file:f)
  10. {
  11. if(file.getName().equals("sdacard0"))//check name of sdcard from file manager.
  12. {
  13. if(file.isDirectory())
  14. {
  15. f = file.listFiles();
  16. }
  17. }
  18. }
  19.  
  20. System.getenv(ENV_EXTERNAL_STORAGE)
  21.  
  22. public static File getExternalStorageDirectory() {
  23. throwIfUserRequired();
  24. return sCurrentUser.getExternalDirs()[0];
  25. }
  26.  
  27. /** {@hide} */
  28. public static File getLegacyExternalStorageDirectory() {
  29. return new File(System.getenv(ENV_EXTERNAL_STORAGE));
  30. }
  31.  
  32. /** {@hide} */
  33. public static File getLegacyExternalStorageObbDirectory() {
  34. return buildPath(getLegacyExternalStorageDirectory(), DIR_ANDROID, DIR_OBB);
  35. }
Add Comment
Please, Sign In to add comment