开发者

Will resource identification numbers stay the same for each install?

开发者 https://www.devze.com 2023-01-14 22:54 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消