2

Can I get resource 'String' from resource id on Android?

eg)

int id = R.drawable.abc;
String ret = getMyResourceString(id);

I need ret is "abc" or "drawable.abc" or "R.drawable.abc"

Can I do this?

pokoso
  • 997
  • 1
  • 6
  • 12

2 Answers2

1

There is two method to get String from resource getResources().getResourceEntryName(int id) or getResource().getResourceName(int id) they have different output, choose what helps you

Shay Kin
  • 2,539
  • 3
  • 15
  • 22
0

I don't think you can get resource string from drawable but yes you can get it from strings.xml file using - getResources().getString(R.string.id)

Prashant_Sarin
  • 114
  • 1
  • 8