0

I have converted Uri into a string by using toString() method and stored in a shared preferences.

String path = uri.toString();

I would like to convert back to Uri so that I can set the image. I have tried

Uri.parse(path); 

or

Uri.fromFile(new File(path));

However, none of them works. How can I set the string back to the Uri?

Chit Khine
  • 830
  • 1
  • 13
  • 34

1 Answers1

1

You can use the parse static method from Uri

Uri myUri = Uri.parse("http://stackoverflow.com")
Shivanshu Verma
  • 609
  • 5
  • 19
  • I think your answer is correct, but I still haven't got what i really wanted. – Chit Khine Mar 15 '17 at 09:40
  • Well then do not check this answer as the right answer. And further this looks like a very bad answer to me. Not to the point at all. – greenapps Mar 15 '17 at 09:45
  • according to my question, this is the right answer but I think I am not asking what i really want since the picture is not displaying but the Uri.parse thing is correct. – Chit Khine Mar 15 '17 at 09:50