MY mENU


Thursday, 9 February 2012

R.java File in Android

The directory gen in an Android project contains generated values. R.java is a generated class which contains references to resources of the res folder in the project. These resources are defined in the res directory and can be values, menus, layouts, icons or pictures or animations. For example a resource can be an image or an XML file which defines strings.

If you create a new resource, the corresponding reference is automatically created in R.java. The references are static int values, the Android system provides methods to access the corresponding resource.

For example to access a String with the reference id R.string.yourString use the method getString(R.string.yourString));. R.java is automatically maintained, manual changes are not necessary.

While the directory res contains structured values which are known to the Android platform the directory assets can be used to store any kind of data. In Java you can access this data via the AssetsManager and the method getAssets().


No comments:

Post a Comment