android - How can I find size of any file from SD_Card? -
i have mp 3
file in sd card , have path of mp 3 / "any extension" file.
now ,
how can size of mp 3 file using code ?
try this
file file=new file(environment.getexternalstoragedirectory(), "lala.mp3"); if(file.exists()){ double bytes = file.length(); double kilobytes = (bytes / 1024); double megabytes = (kilobytes / 1024); double gigabytes = (megabytes / 1024); double terabytes = (gigabytes / 1024); double petabytes = (terabytes / 1024); double exabytes = (petabytes / 1024); double zettabytes = (exabytes / 1024); double yottabytes = (zettabytes / 1024); system.out.println("bytes : " + bytes); system.out.println("kilobytes : " + kilobytes); system.out.println("megabytes : " + megabytes); system.out.println("gigabytes : " + gigabytes); system.out.println("terabytes : " + terabytes); system.out.println("petabytes : " + petabytes); system.out.println("exabytes : " + exabytes); system.out.println("zettabytes : " + zettabytes); system.out.println("yottabytes : " + yottabytes); }else{ system.out.println("file not exists!"); }
Comments
Post a Comment