【问题标题】:Issue in getting size of File in android [duplicate]在android中获取文件大小的问题[重复]
【发布时间】:2017-05-10 06:24:22
【问题描述】:

此代码不适用于我。

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

还有其他获取文件大小的方法吗?

【问题讨论】:

  • Is there any another method to get size of file?? - 所以不能这样工作。你不能在这里收集所有的方式。 This Code is not working for me.. 究竟如何?它会崩溃吗?还是什么?

标签: android file outputstream fileinputstream


【解决方案1】:

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);

【讨论】:

  • 这与所使用的方式相匹配。这不是另一种方式
猜你喜欢
  • 1970-01-01
  • 2021-02-04
  • 2011-08-19
  • 2018-05-08
  • 1970-01-01
  • 2011-10-13
  • 2011-10-31
相关资源
最近更新 更多