AndroidDev
AndroidDev

Reputation: 16385

Android R file update at runtime

Is it possible to examine the R file and update its contents via reflection in an Android application. I was looking to change the value various constants defined in the R file ? Is it possible ? Would it make sense ?

Upvotes: 0

Views: 118

Answers (2)

Szymon
Szymon

Reputation: 43023

It is not possible and, in my opinion, it wouldn't make sense.

The values in the R class change when you build your application and you can never guarantee that they will be the same. The integer values are not meant to be used directly, only they static constants should be used in your code.

Upvotes: 2

flx
flx

Reputation: 14226

It's not possible and it would not make sense.

R is a set of static fields. There is nothing you can do to change that. Everything is baked into it on compile time.

Upvotes: 2

Related Questions