Android get image path from drawable as string

前端 未结 5 591
天涯浪人
天涯浪人 2020-12-04 19:15

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 us

5条回答
  •  既然无缘
    2020-12-04 20:06

    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();
    

提交回复
热议问题