iOS

 1NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
 2NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error:nil];
 3
 4if (dictionary) {
 5    int GiB = 1024*1024*1024;
 6    float free = [[dictionary objectForKey: NSFileSystemFreeSize] floatValue]/GiB;
 7    float total = [[dictionary objectForKey: NSFileSystemSize] floatValue]/GiB;
 8    NSLog(@"Space: %.3f", free);
 9    NSLog(@"Total: %.3f", total);
10}

Android

ディレクトリのパスはいくつかとれますが、デバイスによって使われ方がどうも違うっぽい感じがしました。

写真のデータ置き場はgetDataDirectoryで取れるパスが正解のような感じ。

  • Environment.getDataDirectory()
  • Environment.getExternalStorageDirectory()
  • Environment.getRootDirectory()

参考

データ/キャッシュ/外部ストレージ/システムのパスを取得するには - 逆引きAndroid入門

1long MEGA_BYTE = 1048576;
2String path = Environment.getDataDirectory().getAbsolutePath();
3
4StatFs statFs = new StatFs(path);
5long availableBlocks = statFs.getAvailableBlocks();
6long blockSize = statFs.getBlockSize();
7long freeBytes = availableBlocks * blockSize;
8
9Log.d("MyApp", "Free:" + (freeBytes / MEGA_BYTE));