Why do I have to import R class when I use resource in a non-root package?
<p>Whenever I want to use any resource element in the non-root package, I have to import my own <code>R class</code> (not Android R class). For example,</p>

<p>Root package <code>com.example.test</code> and a file <code>Main.java</code></p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
</code></pre>

<p>No need to import <code>R class</code>. </p>

<p>When I create another package, <code>com.example.test.something</code> and a new class in there <code>Something.java</code>, I have to import my own <code>R.class</code></p>

<pre><code>import com.example.test.R;

//...other code...

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
</code></pre>

<p>This happens automatically when I move a Java file from root to non-root package. </p>

<p>Why is this so important?</p>
