Possible Duplicate:
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 cha开发者_StackOverflownce 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?
Thanks
You can get the size of the file in bytes thus:
File f = new File(uri.getPath());
long size = f.length();
精彩评论