-2

This Code is not working for me.

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

Is there any another method to get size of file?

Draken
  • 3,134
  • 13
  • 34
  • 54
Nathani Software
  • 111
  • 1
  • 1
  • 7
  • `Is there any another method to get size of file??` - SO doesn't work this way. You can't just collect all ways here. `This Code is not working for me..` how exactly? does it crash? Or what? – Vladyslav Matviienko May 10 '17 at 06:55

1 Answers1

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