I am getting an error like below when I calling this to get External Memory Details.
05-07 16:55:07.710: E/AndroidRuntime(22624): FATAL EXCEPTION: main java.lang.IllegalArgumentException: Invalid path: /storage/emulated/0
05-07 16:55:07.710: E/AndroidRuntime(22624): at android.os.StatFs.doStat(StatFs.java:46)
05-07 16:55:07.710: E/AndroidRuntime(22624): at android.os.StatFs.<init>(StatFs.java:39)
It was works before i update my android to SAMSUNG Galaxy S3 4.3. I followed this post.This is my Code:
// getting available memory
public static String getAvailableExternalMemorySize() {
if (externalMemoryAvailableBool()) {
// File path =
// Environment.getExternalStorageDirectory().getAbsolutePath();
StatFs stat = new StatFs(Environment.getExternalStorageDirectory()
.getAbsolutePath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return formatSize(availableBlocks * blockSize);
} else {
return ERROR;
}
}
// getting total memory
public static String getTotalExternalMemorySize() {
if (externalMemoryAvailableBool()) {
File path = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long totalBlocks = stat.getBlockCount();
return formatSize(totalBlocks * blockSize);
} else {
return ERROR;
}
}
I want to get Available & Total Memory of my External Memory Card.