StackOverflowed
StackOverflowed

Reputation: 5975

R.id/.layout/.string resource IDs don't change after compile, correct?

From the documentation: "The Android SDK tools compile your application's resources into the application binary at build time.". So it's safe to assume that all Resource ids will be the same, no matter which device is running them?

Upvotes: 1

Views: 555

Answers (2)

laalto
laalto

Reputation: 152817

Yes, the constant values will be the same.

However, I'm not sure how this information is useful in any meaningful way. The values can change from one build to another, e.g. when you're modifying your resources and then re-building the app. Using the value to communicate something outside the app is therefore fragile.

Upvotes: 2

Prateek
Prateek

Reputation: 4013

No you can't trust the R file that could change if you have such a case you should better set a Tag with your view and use it. Well that is not recommended.

Upvotes: 0

Related Questions