Android Uri to Filesize
Android: Get the size of a file in resources?
I want to upload a file to a WebServer. To show the progress of the upload I need to know the complete size of the file. Since I have only the Uri of the file (got it from an Intent), I have no chance to get at the file’s size. My workaround is to open an InputStream and count the bytes that are read on this InputStream. But this is circuitous. Is there an easier/conventional way to solve this issue?
One Solution collect form web for “Android Uri to Filesize”
You can get the size of the file in bytes thus:
File f = new File(uri.getPath()); long size = f.length();