title: android.content.res.Resources$NotFoundException: String array resource ID #0x0 while accessing getResource()
body: <p>I'm really new to Android. I am getting this error(application is crashing) while running it.
  I am trying to access string array in my main.java by calling the getResources().
  But Resource Not Found Exception is thrown. Please have a look at my code given below :</p>
  
  <pre><code> import android.os.Bundle;
      import android.content.res.Resources;
      import android.app.Activity;
      import android.view.Menu;
      import android.view.ViewGroup;
      import android.widget.*;
     //import com.packtpub.kitchendroid.R;
  
      public class QuestionActivity extends Activity {
  
      private Button[] buttons;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_question);
          initQuestionScreen();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.question, menu);
          return true;
      }
  
      private static int getQuestionId(final Resources res,final int index)
      {
          final String[] questions = res.getStringArray(R.array.questions);
          return     res.getIdentifier(questions[index],"array","com.packtub.kitchendroid");
      }
  
      private int getQuestionIndex()
      {
          return getIntent().getIntExtra("KitchenDroid.Question", 0);
      }
  
      private void initQuestionScreen()
      {
          TextView question = (TextView)findViewById(R.id.question);
          ViewGroup answers = (ViewGroup)findViewById(R.id.answers);
              Resources resources1 = getResources();
          int questionID = getQuestionId(resources1, getQuestionIndex());
          String[] questionData = resources1.getStringArray(questionID);
          question.setText(questionData[0]);
          int answerCount = questionData.length -1;
          buttons = new Button[answerCount];
          for(int i=0;i&lt;answerCount;i++)
          {
              String answer = questionData[i+1];
              Button button = new Button(this);
              button.setText(answer);
              answers.addView(button);
              buttons[i]=button;
  
            }
  
  
              }
      }
  </code></pre>
  
  <hr>
  
  <p>my xml is as follows :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;resources&gt;
  
          &lt;string name="app_name"&gt;Kitchen Droid&lt;/string&gt;
          &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
          &lt;string name="question"&gt;Please wait&lt;/string&gt;
          &lt;string name="skip"&gt;Skip Question&lt;/string&gt;
          &lt;string name="feedme"&gt;Feed Me!..&lt;/string&gt;
          &lt;string-array name="questions"&gt;
              &lt;item&gt;vegetarian&lt;/item&gt;
              &lt;item&gt;size&lt;/item&gt;
          &lt;/string-array&gt;
          &lt;string-array name="vegetarian"&gt;
               &lt;item&gt;Are you a vegeterian?&lt;/item&gt;
               &lt;item&gt;Yes&lt;/item&gt;
               &lt;item&gt;No&lt;/item&gt;
               &lt;item&gt;I\'m a vegetarian&lt;/item&gt;
          &lt;/string-array&gt;
         &lt;string-array name="size"&gt;
              &lt;item&gt;How much do you feel like eating?&lt;/item&gt;
              &lt;item&gt;A large meal&lt;/item&gt;
              &lt;item&gt;Just a nice single serving of food&lt;/item&gt;
              &lt;item&gt;Some finger foods&lt;/item&gt;
              &lt;item&gt;Just a snack&lt;/item&gt;
          &lt;/string-array&gt;
      &lt;/resources&gt;
  </code></pre>
  
  <p>Please help me out with this issue.Apologies if the question is not appropriate as I am completely new to Android</p>