title: How to programmatically get resource Id for android.R.id.content?
body: <p>I'm trying to do this in a library project...</p>
  
  <pre><code>int containerViewId = getResources().getIdentifier("content", "android.R.id", getPackageName());
  
  getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();
  </code></pre>
  
  <p>But I get this exception on the replace:
      Caused by: java.lang.IllegalArgumentException: Must use non-zero containerViewId</p>
  
  <p>How do I get resource id for android.R.id.content programmatically?</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit:</strong>
  I have solved it by using a named view, setting the id in the xml layout of the activity and using the following code to replace the root view...</p>
  
  <pre><code>int containerViewId = getResources().getIdentifier("rootView", "id", getPackageName());
  getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();
  </code></pre>