Will resource identification numbers stay the same for each install?
my goal:
create an image gallery with each image having a description, name, title, other possible misc info. as the user navigates through the gallery, image info will be displayed. i plan to store the data in an arraylist of maps ArrayList<Map<String, String>>
which is filled from the database. the list will include resource ID values among image info.
problem:
I am saving drawable resource ID values in an SQLite database when the app is opened for the first time. from then on, i will be referring to the sqlite stored r开发者_StackOverflow社区esource ID values, and not directly retrieving resources by this R.drawable.drawable_name
fashion. can i guarantee that the resource ID values will never change after the app is installed?
The Resource IDs are generated when your application is compiled so they won't change after the application is installed.
However if you release a new version of your application the Resource IDs almost certainly will change. So you will need to detect an upgrade and rebuild your DB or just not access resources this way.
If you say what problem you are solving by putting Resource IDs in the database someone may be able to give you a less brittle solution.
I am saving drawable resource ID values in an SQLite database when the app is opened for the first time.
That is a bad idea.
can i guarantee that the resource ID values will never change after the app is installed?
No. They will vary from compile to compile.
Yes.
If you open R.java
you will notice that every property is defined as public static final
.
精彩评论