Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
- double sdAvailSize = (double)stat.getAvailableBlocks()
- * (double)stat.getBlockSize();
- //One binary gigabyte equals 1,073,741,824 bytes.
- double gigaAvailable = sdAvailSize / 1073741824;
- File dir = new File(Environment.getExternalStorageDirectory().getParent());
- File[] f = dir.listFiles();
- for(File file:f)
- {
- if(file.getName().equals("sdacard0"))//check name of sdcard from file manager.
- {
- if(file.isDirectory())
- {
- f = file.listFiles();
- }
- }
- }
- System.getenv(ENV_EXTERNAL_STORAGE)
- public static File getExternalStorageDirectory() {
- throwIfUserRequired();
- return sCurrentUser.getExternalDirs()[0];
- }
- /** {@hide} */
- public static File getLegacyExternalStorageDirectory() {
- return new File(System.getenv(ENV_EXTERNAL_STORAGE));
- }
- /** {@hide} */
- public static File getLegacyExternalStorageObbDirectory() {
- return buildPath(getLegacyExternalStorageDirectory(), DIR_ANDROID, DIR_OBB);
- }
Add Comment
Please, Sign In to add comment