Linked Questions
10 questions linked to/from Android- how can I convert android.net.Uri object to java.net.URI object?
22 votes
2 answers
34k views
How to convert android.net.Uri to java.net.URL? [duplicate]
Is there a way to convert from Uri to URL? I need this for a library I'm using, it only accepts an URL but I need to use an image on my device.
448 votes
32 answers
471k views
Get filename and path from URI from mediastore
I have an onActivityResult returning from an mediastore image selection which I can get a URI for an image using the following: Uri selectedImage = data.getData(); Converting this to a string gives ...
27 votes
3 answers
20k views
Convert java.net.URI to android.net.Uri
I am able to find how to convert android.net.Uri to Java.net.URI here but not vice-versa. So after spending some time I figured it out. Here is the solution(If there is another solution then please ...
32 votes
1 answer
24k views
Android Uri to Filesize [duplicate]
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 ...
4 votes
2 answers
11k views
Uri.toString() returns a reference instead of the String
When attempting to execute this code in an Android Activity: Uri testurl = Uri.parse("http://www.google.com"); Log.v("HTTPGet", "testurl.toString == " + testurl.toString()); the only output in Logcat ...
6 votes
1 answer
6k views
Android: construct a File from an android.net.URI
I have an android.net.URI object (of the kind returned by onActivityResult after MediaStore.ACTION_VIDEO_CAPTURE): it looks like content://media/video/media/33. I want to convert this into a File ...
1 vote
6 answers
4k views
Convert a string to a resource Uri for mp3 playback
I am trying to play an mp3 using the Media player class. When I hardcode the mp3 resource it works, however I would like the resource to come from a string instead of directly accessing it like R.raw....
2 votes
1 answer
3k views
How to delete a video recorded using an Intent with ACTION_VIDEO_CAPTURE?
I would like to remove a video that has been previously recorded using an Intent: Intent captureVideoIntent = new Intent( android.provider.MediaStore.ACTION_VIDEO_CAPTURE); ...
0 votes
1 answer
235 views
convert android.net.Uri to java.net.uri
i'm following along this answer: Android- how can I convert android.net.Uri object to java.net.URI object? android.net.Uri INPUT_FILE; java.net.URI juri = new java.net.URI(INPUT_FILE.toString()); File ...
0 votes
1 answer
208 views
How do you fix type mismatch error when picking contacts?
On this line in val contactUri: Uri? = data.data … val cursor = requireActivity().contentResolver .query(**contactUri**, queryFields, null, null, null) Type mismatch required Uri got Uri How ...