Search code examples
javaandroidr.java-file

Resource IDs and Devices


My question for anyone that can answer concerns the generated resource IDs in android projects. I am familiar with what they are and that they are automatically created for me.

I am wondering if any particular resource number, that is, the actual integer value, will be consistent across all devices when an android app is published in the marketplace. My assumption would be yes, the resources are just that: definitive (public static final) numbers that the device uses to map and track resources. As such, it would then seem that the number values should be the same across every installation (and also will never change). For example, if I have:

public static final int button1=0x7f020011;

in R.java, will this number be consistent across every device that installs the app from the marketplace? Or might each particular device have its own uniquely defined integer value that is used to refer to the resource "button1"?

If anyone could offer me clarification or more information on this it would be very much appreciated.

Thanks.


Solution

  • I am wondering if any particular resource number, that is, the actual integer value, will be consistent across all devices when an android app is published in the marketplace.

    Yes. They are part of your app.

    As such, it would then seem that the number values should be the same across every installation (and also will never change).

    They may change between builds, as they are code-generated as part of your app.

    in R.java, will this number be consistent across every device that installs the app from the marketplace?

    They will be consistent for everyone who has a particular version of your app installed. Different versions of your app may have different numbers, and your users will be using a mix of versions of your app, as not everyone will necessarily take on every update as soon as it is available.