Android Basics – What is an R file ?

R is a Java Class file which is autogenerated by Android for your Project. It contains a list of all Resources being used.

For example if you have the following TextView in your Layout

<TextView
android:id=”@+id/helloId”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Hello Android !!”/>

Android will create the following entry in the R file for this ID.

public static final int helloId=0x7f0c0069;

This helps us to reference this UI component in our Activity Class.