title: How to get value from a string in Android
body: <p>I started programming android application, but get stuck in a part where I need to get values from string.
  At this moment trying to make Calculator for Android. At this example I'm trying to get values just for add two values.</p>
  
  <p>Adding my code:</p>
  
  <blockquote>
    <p>MainActivity.java</p>
  </blockquote>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  @Bind({R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6, R.id.button7, R.id.button8,
          R.id.button9, R.id.buttonDot, R.id.buttonC, R.id.buttonDeleteLastSymbol, R.id.buttonMultiplication, R.id.buttonDivision, R.id.buttonSubtraction, R.id.buttonEqual})
  List&lt;Button&gt; button;
  @Bind(R.id.editText1)
  EditText editText;
  
  public String sign = "";
  public Double mathDouble, mathDouble2;
  
  static final ButterKnife.Action&lt;View&gt; DISABLE = new ButterKnife.Action&lt;View&gt;() {
      @Override
      public void apply(View view, int index) {
          view.setEnabled(false);
      }
  };
  static final ButterKnife.Setter&lt;View, Boolean&gt; ENABLED = new ButterKnife.Setter&lt;View, Boolean&gt;() {
      @Override
      public void set(View view, Boolean value, int index) {
          view.setEnabled(value);
      }
  };
  
  //Buttons 0-9
  @OnClick({R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4, R.id.button5, R.id.button6, R.id.button7, R.id.button8,
          R.id.button9, R.id.buttonDot})
  void inputValue(Button button) {
      editText.append(button.getText());
  }
  
  @OnClick({R.id.buttonPlus, R.id.buttonSubtraction, R.id.buttonDivision, R.id.buttonMultiplication})
  void inputSign(Button button) {
      sign = button.getText().toString();
      editText.append(sign);
  }
  
  public Double FirstValue() {
      String writtenText = editText.getText().toString();
      String firstValue = writtenText.substring(0, writtenText.indexOf("+"));
  
      return mathDouble = Double.parseDouble(firstValue);
  }
  
  Double SecondValue() {
      String writtenText = editText.getText().toString();
      String secondValue = writtenText.substring(writtenText.indexOf("+") + 1, writtenText.charAt(writtenText.length() - 1));
      return mathDouble2 = Double.parseDouble(secondValue);
  }
  
  //Buttons Equal, CE and C
  @OnClick(R.id.buttonC)
  void WriteLeftBracket() {
      editText.setText(String.valueOf(""));
  }
  
  @OnClick(R.id.buttonDeleteLastSymbol)
  void WriteRightBracket() {
      if (editText.getText().toString().length() &gt; 0) {
          editText.setText(editText.getText().toString().substring(0, editText.getText().toString().length() - 1));
          editText.setSelection(editText.getText().length());
      }
  }
  
  @OnClick(R.id.buttonEqual)
  void Equal(Button button) {
      editText.append(button.getText());
      editText.setText(Double.toString(mathDouble + mathDouble2));
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      ButterKnife.bind(this);
  }
  }
  </code></pre>
  
  <blockquote>
    <p>content_main.xml</p>
  </blockquote>
  
  <pre><code>&lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:context=".MainActivity"
      tools:showIn="@layout/activity_main"&gt;
  
      &lt;LinearLayout
          android:id="@+id/layout1"
          android:layout_width="match_parent"
          android:layout_height="60dp"&gt;
  
          &lt;EditText
              android:id="@+id/editText1"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:singleLine="true"
              android:lines="1"
              /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/layout1"&gt;
  
          &lt;Button
              android:id="@+id/buttonC"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:text="@string/erase"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/buttonDeleteLastSymbol"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:text="@string/delete"
              android:textStyle="bold"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/buttonMultiplication"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:text="@string/multiplication"
              android:textSize="30sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout1"&gt;
  
          &lt;Button
              android:id="@+id/button7"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/seven"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button8"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/eight"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button9"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/nine"
              android:textSize="30sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout2"&gt;
  
          &lt;Button
              android:id="@+id/button4"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/four"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button5"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/five"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button6"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/six"
              android:textSize="30sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout3"&gt;
  
          &lt;Button
              android:id="@+id/button1"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/one"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button2"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/two"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/button3"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/three"
              android:textSize="30sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout5"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/linearLayout4"&gt;
  
          &lt;Button
              android:id="@+id/button0"
              android:layout_width="160dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/zero"
              android:textSize="30sp" /&gt;
  
          &lt;Button
              android:id="@+id/buttonDot"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/dot"
              android:textSize="30sp" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/linearLayout6"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@id/layout1"
          android:layout_toRightOf="@id/linearLayout1"&gt;
  
          &lt;Button
              android:id="@+id/buttonDivision"
              android:layout_width="80dp"
              android:layout_height="80dp"
              android:layoutDirection="inherit"
              android:text="@string/division"
              android:textSize="30sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          android:id="@+id/buttonSubtraction"
          android:layout_width="80dp"
          android:layout_height="80dp"
          android:layout_below="@+id/linearLayout1"
          android:layout_toEndOf="@+id/linearLayout1"
          android:text="@string/subtraction"
          android:textSize="30sp" /&gt;
  
      &lt;Button
          android:id="@+id/buttonEqual"
          android:layout_width="80dp"
          android:layout_height="80dp"
          android:layout_below="@+id/linearLayout2"
          android:layout_toEndOf="@+id/linearLayout1"
          android:text="@string/equal"
          android:textSize="30sp" /&gt;
      &lt;Button
          android:id="@+id/buttonPlus"
          android:layout_width="80dp"
          android:layout_height="160dp"
          android:layout_below="@+id/linearLayout3"
          android:layout_toEndOf="@+id/linearLayout1"
          android:text="@string/plus"
          android:textSize="30sp"
  
          /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>strings.xml</p>
  </blockquote>
  
  <pre><code>    &lt;resources&gt;
      &lt;string name="app_name"&gt;Calculator&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="dot"&gt;.&lt;/string&gt;
      &lt;string name="plus"&gt;+&lt;/string&gt;
      &lt;string name="subtraction"&gt;-&lt;/string&gt;
      &lt;string name="division"&gt;/&lt;/string&gt;
      &lt;string name="multiplication"&gt;*&lt;/string&gt;
      &lt;string name="equal"&gt;=&lt;/string&gt;
      &lt;string name="erase"&gt;C&lt;/string&gt;
      &lt;string name="delete"&gt;←&lt;/string&gt;
  
      //Numbers
      &lt;string name="one"&gt;1&lt;/string&gt;
      &lt;string name="two"&gt;2&lt;/string&gt;
      &lt;string name="three"&gt;3&lt;/string&gt;
      &lt;string name="four"&gt;4&lt;/string&gt;
      &lt;string name="five"&gt;5&lt;/string&gt;
      &lt;string name="six"&gt;6&lt;/string&gt;
      &lt;string name="seven"&gt;7&lt;/string&gt;
      &lt;string name="eight"&gt;8&lt;/string&gt;
      &lt;string name="nine"&gt;9&lt;/string&gt;
      &lt;string name="zero"&gt;0&lt;/string&gt;
      &lt;string name="illegal_argument_exeption"&gt;Cannot Divide By Zero!&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>