Android Uri to Filesize

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 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?

  • Custom Adapter getView() method is not called
  • android.content.ActivityNotFoundException: Unable to find explicit activity class
  • Expandable list with RecyclerView?
  • foreign key constraint ON DELETE CASCADE not working in sqlite database on android
  • Cordova 2.1.0 (PhoneGap) create script for Android says “Project already exists” or “An error occurred. Deleting project”
  • custom view with layout
  • Thanks

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.