android - How to calculate selected image size in gallery? -


have edited question make more clear.

basically working on app users need upload profile image. need limit size of image upload less 4mb. here user selects image image gallery, @ instant need check image file's size , show alert user if file size greater 4mb , restrict upload.

presently using code file size:

file img = new file(selectedimage.getpath()); int length = img.length();

i know length() returns file size in bytes, after conversion bytes mb, seems return small values original image file size leading me believe getting file size way inaccurate.

is there other way can file size of image files device gallery?

any appreciated. guys.

actually, question little bit unclear: size 'in kb' or youhave know how seen on screen??

will help?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -