LetsamrIt LetsamrIt - 2 months ago 13
Android Question

Ho to access R.java programmatically

How to access

R.java
programmatically?
I know the path to
R.java
class on the C: drive
but I want to access it programmatically in Android, can I access
R.java
using either of
Environment.getExternalStorageDirectory()
or
openFileInput
?

Answer Source

can I access R.java using either of Environment.getExternalStorageDirectory() or openFileInput ?

No.

R.java is a source file, written in a programming language called Java. Java is a compiled language; the source code to R.java is compiled as part of building your app. The source code itself is not in the app.

You can access the values of the constants defined in R.java programmatically. In fact, that is the point of the R class: give you values that you can use to identify resources. Every time your code has R.layout.main or R.string.app_name or R.mipmap.ic_launcher, you are programmatically referring to R.