Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将文件保存在应用程序私有文件夹“getFilesDir().getAbsolutePath()”上。我想知道在保存到该位置之前有多少可用空间。
如果没有足够的可用空间,则强制用户删除一些文件以释放空间。
我如何确定有多少可用空间?
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath()); long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount(); long megAvailable = bytesAvailable / 1048576; System.out.println("Megs :"+megAvailable);
来源链接