how can you retrieve yours phone internal storage from an app? I found memoryinfo, but it seems that returns information on how much memory your currently running tasks. I am trying to get my app to retrieve how much internal phone storage is available.
+3
A:
Use android.os.Environment
to find the internal directory, then use android.os.StatFs
to call the Unix statfs
system call on it. Shamelessly stolen from the Android settings app:
File path = Environment.getDataDirectory();
StatFs stat = new StatFs(path.getPath());
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return Formatter.formatFileSize(this, availableBlocks * blockSize);
jleedev
2010-04-16 13:07:31
@jleedev nice solution, thanks
systempuntoout
2010-04-16 13:31:10
thanks, I will try this out later :)
John
2010-04-16 13:51:53
works great, thanks!
John
2010-04-16 16:36:57
@John Thanks and welcome to Stack Overflow. If you click the check mark next to the answer, it will mark it as accepted.
jleedev
2010-04-16 18:08:02