Do the values ​​in R.java know at run time or between runs?

I am developing a method for storing some values ​​in SharedPreferences that are related to a set of views. This method will be launched by a group of subclasses, so I need an easy way to store the settings names, and I am considering using R.id values ​​for representations, since I already have them in ArrayList for another method. However, I'm a little worried that these values ​​may vary between runs, which will actually invalidate the saved settings. Do they ever change beyond development?

+4
source share
1 answer

They also do not change between compilations.

R is a class that is automatically generated during the build process of the application. It is then compiled and serves as a regular class in your application.

From Android documents - Access to resources :

When your application is compiled, aapt generates an R class that contains resource identifiers for all resources in the res / directory. For each resource type, there is a subclass of R (for example, R.drawable for all available resources) and for each resource of this type, there is a static integer (for example, R.drawable.icon). This integer is a resource identifier that you can use to retrieve your resource.

+6
source

Source: https://habr.com/ru/post/1411912/


All Articles