IndexOutOfBoundsException in Edit Text for android
<p>i have an edit text in my activity.i am entering numbers in it manually but </p>

<pre><code>   int mystart = destinationNumber.getSelectionStart();
   int myend = destinationNumber.getSelectionEnd();
   numberText.getText().replace(Math.min(mystart, myend), Math.max(mystart, myend),
                        "1", 0, 1);
</code></pre>

<p>its entering fine according to the cursor position.</p>

<p>i have a delete button in my acitivity which deletes single character according to cursor postion.</p>

<pre><code>numberText.getText().delete(myend - 1, mystart);
</code></pre>

<p>But this logic is not working properly when i select whole text and call delete method it gives me IndexOutOfBoundsException OR i select 4-5 digits and call this delete.</p>

<p>I want the same functionality as android contact dialpad number enter field.Can someone help me figure out what is the correct logic to delete single digit from edittext and multiple selected digits as well.</p>

<p>Thanks</p>
