Android- how can I convert android.net.Uri object to java.net.URI object?

You could use the toString method of the android Uri in combination of the String based constructor of the Java URI.

android.net.Uri auri = new android.net.Uri(what ever);
java.net.URI juri = new java.net.URI(auri.toString());

Android URI | Java URI


Found the correct way to open InputStream from content URI:

InputStream fileInputStream=yourContext.getContentResolver().openInputStream(uri);

That's all!


There is a solution to your original question (convert Uri to URI):

  1. Get the real file path (look this code: Get filename and path from URI from mediastore)

  2. Get the URI using the real path and the constructor: URI(String uri)

If you need more details, look here:

How to delete a video recorded using an Intent with ACTION_VIDEO_CAPTURE?