Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android get image path from drawable as string

Is there any way that I can get the image path from drawable folder in android as String. I need this because I implement my own viewflow where I'm showing the images by using their path on sd card, but I want to show a default image when there is no image to show.

Any ideas how to do that?

like image 705
Android-Droid Avatar asked Dec 22 '11 08:12

Android-Droid


1 Answers

These all are ways:

String imageUri = "drawable://" + R.drawable.image; 

Other ways I tested

Uri path = Uri.parse("android.resource://com.segf4ult.test/" + R.drawable.icon); Uri otherPath = Uri.parse("android.resource://com.segf4ult.test/drawable/icon");  String path = path.toString(); String path = otherPath .toString(); 
like image 178
karan Avatar answered Oct 02 '22 17:10

karan