Issue
I need to store the link to the image, which user has chosen. The sources of the images are files, contact icons and resources' drawables (I need drawables since I provide different images for different resolutions/densities).
For the purpose of unification I store it in URI, and consequently this URI may be pointing to a file (file://
), to content provider or to resource (android.resource://...
). Here is how the URI pointing to drawable with id=2130837534 looks like:
android.resource://my.packagename/2130837534
It works fine unless the ids in R.java
are regenerated. So, is there any way to prevent SDK from changing some of the R.java
ids values?
Solution
No you can't, and shouldn't. If you can describe your problem clearly, there might be some other solution.
Save your resource names in a file, in this way.
icon_profile_1 icon_profile_2
And then when you need the resource ID, do this.
int resID = getResources().getIdentifier("icon_profile_1", "drawable","your_package_name");
Check here(java.lang.String, java.lang.String, java.lang.String)
Answered By - Kumar Bibek
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.