Chit Khine
Chit Khine

Reputation: 850

How to convert the string to Uri after storing in shared preferences?

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?

Upvotes: 0

Views: 464

Answers (1)

Shivanshu Verma
Shivanshu Verma

Reputation: 601

You can use the parse static method from Uri

Uri myUri = Uri.parse("http://stackoverflow.com")

Upvotes: 1

Related Questions