我在用着:
FileOutputStream fos = getContext().openFileOutput(FILENAME, Context.MODE_APPEND);
将数据字符串存储到文件FILENAME中。我想确保当 FILENAME 中的字符串达到 120kB 时,我将停止追加任何字符串。如何查询占用的总空间?
我试过了:
File file = new File(getContext().getFilesDir() + "/" + FILENAME);
Log.i(TAG, "Storage Used (Bytes): " + Long.toString(file.getTotalSpace()));
但它返回给我一个巨大的数字。可能是因为我引用目录的方式是错误的?