Reputation: 1537
Let's say I want to create a database with static references to images included in my Android App. If I use the drawable folder, the ids are dynamic and I can't use a static reference to them.
Since I want to use one column of my Database as a resource for suggestion icons in my App, using drawables files is not simple...
If I want to do it, in which folder should I put my .png files? And in the database, which url should I save for each entry?
Upvotes: 0
Views: 48
Reputation: 39846
it's actually pretty simple to use in the normal drawable folders and write in the DB as string/text.
the Resources
object have a few methods to help you deal with it:
getIdentifier(...)
use this to get the integer ID of the drawable, for example:
context.getResources().getIdentifier("icon", "drawable", context.getPackageName());
and getResourceEntryName(...)
use this to get the String name of the drawable, for example:
context.getResourceEntryName(R.drawable.icon);
Upvotes: 1