Is it possible to convert an Uri to String and vice versa?
Because I want to get the the Uri converted into String to pass into another activity via intent.putextra() and if it's not possible can anyone suggest me a way how to pass selected Uri into another activity?
7 Answers
Uri is serializable, so you can save strings and convert it back when loading
when saving
String str = myUri.toString();
and when loading
Uri myUri = Uri.parse(str);
1 Comment
Alberto Solano
 Please provide more details. Add some notes about your choices. I think they could be helpful.
  If you want to pass a Uri to another activity, try the method intent.setData(Uri uri) https://developer.android.com/reference/android/content/Intent.html#setData(android.net.Uri)
In another activity, via intent.getData() to obtain the Uri.





Uri.parse()is not intuitive, and especially not when the reverse isuri.toString();(i would have thought it would beUri.stringify()or something. definitely upvoting this question.