Avoid using a deprecated API if possible.

This commit is contained in:
akwizgran
2013-11-19 23:13:35 +00:00
parent a56516f8a6
commit e73dc148c3

View File

@@ -4,12 +4,15 @@ import java.io.File;
import java.io.IOException;
import net.sf.briar.api.os.FileUtils;
import android.os.Build;
import android.os.StatFs;
class AndroidFileUtils implements FileUtils {
public long getFreeSpace(File f) throws IOException {
StatFs s = new StatFs(f.getAbsolutePath());
if(Build.VERSION.SDK_INT >= 18)
return s.getAvailableBlocksLong() * s.getBlockSizeLong();
return (long) s.getAvailableBlocks() * s.getBlockSize();
}
}