title: Reading XML Strings from Java
body: <p>With something that I thought was so simple, I'm surprised to be getting such a strange error...</p>
  
  <p>In my program, I have a layout with 5 buttons on it.  When you press a button, it launches the phone's dialer with the number pre-loaded into it.  I've had no problem with this before, but then I tried moving the phone numbers to strings in an XML file that I put in the /res/values folder called 'phone.xml'.  Here's a portion of my code for the Java file:</p>
  
  <pre><code>    public void launchDialer(String number){
          String numberToDial = "tel:"+number;
          startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(numberToDial)));
      }
  
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.police_button1:
              launchDialer(Integer.toString(R.string.police1_phone));
              break;
          case R.id.police_button2:
              launchDialer("" + R.string.police2_phone);
              break;
          case R.id.police_button3:
              launchDialer("" + R.string.police3_phone);
              break;
          case R.id.police_button4:
              launchDialer("" + R.string.police4_phone);
              break;
          case R.id.police_button5:
              launchDialer("" + R.string.police5_phone);
              break;
          }
      }
  </code></pre>
  
  <p>And here's my phone.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string name="police1_phone"&gt;"555-555-5555"&lt;/string&gt;
      &lt;string name="police2_phone"&gt;1-800-555-5555&lt;/string&gt;
      &lt;string name="police3_phone"&gt;555-555-5555&lt;/string&gt;
      &lt;string name="police4_phone"&gt;555-555-5555&lt;/string&gt;
      &lt;string name="police5_phone"&gt;555-555-5555&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>As you can see in the Java file, I tried something different for police1_phone and police2_phone, but neither of them worked. You can also see I tried putting quotes around 1 of the phone numbers in the xml file, but it still didn't work.  My output has always been some random 7 digit number that wasn't even close to the phone number I wanted it to print. This Java code worked:</p>
  
  <pre><code>launchDialer("555-555-5555");
  </code></pre>
  
  <p>But, I <strong>need</strong> it to read from an XML file.  Any ideas?</p>