I have some image names stored in a database, but the images
themselves are in the /res/drawable folder of the application.

I need to assign these images to some views at runtime, and I'm
currently doing it this way:


//------------------------------------------------------

public static final String DRAWABLES_PATH = ":drawable/";

int resId = getResources().getIdentifier(packageName+DRAWABLES_PATH
+imageName,null,null);
mButtonX.setBackgroundResource(resId);

//------------------------------------------------------

Is there a more efficient way to do it ?

or should I be storing the images directly in the database (they are
many) ?

Any thoughts really appreciated.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to