在android中获取File大小的问题

时间:2017-05-10 06:24:23

标签: android file outputstream fileinputstream

本规范对我不起作用。

long length = file.length();
length = length/1024;

是否有其他方法可以获取文件大小?

1 个答案:

答案 0 :(得分:0)

File file =new File("//data/data/Your-Application-Package-Name/File/your-file-name"); double bytes = file.length(); double kilobytes = (bytes / 1024); double megabytes = (kilobytes / 1024);Log.d("file size","size of file in KB:"+kilobytes); Log.d("file size","size of file in MB:"+megabytes);