Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the size of a file in Android

Tags:

java

file

android

I am looking to find the size of a file in Android. I originally expected it to be as simple as a size() method in File, or something along those lines. But I haven't been able to find anything. Any help would be greatly appreciated.

Thanks

like image 717
jln646v Avatar asked Apr 29 '11 23:04

jln646v


1 Answers

Use file.length()

http://download.oracle.com/javase/6/docs/api/java/io/File.html#length%28%29

The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.

like image 65
corsiKa Avatar answered Oct 03 '22 21:10

corsiKa