title: EditText cursor position when backspace/delete press while TextWatcher is present
body: <p>I have EditText which have custom TextWatcher. When user move cursor position manually and delete some character it always go to end position. How to maintain same position of the cursor when he press delete/backspace?</p>
  
  <pre><code>  private class CTextWatcher implements TextWatcher {
      private final EditText editText;
  
  
      CTextWatcher(EditText editText, String prefix) {
          this.editText = editText;
          this.prefix = prefix;
      }
  
      @Override
      public void beforeTextChanged(CharSequence s, int start, int count, int after) {
          // do nothing
      }
  
      @Override
      public void onTextChanged(CharSequence s, int start, int before, int count) {
          // do nothing
      }
  
      @Override
      public void afterTextChanged(Editable editable) {
  
           editText.removeTextChangedListener(this); // Remove listener
          editText.setText(formattedString);
            editText.setSelection(editText.getText().length());
          editText.addTextChangedListener(this); // Add back the listener
      }
  </code></pre>
  
  <p>For example, I have <code>text = 1234</code> and user move cursor before <code>3</code> and press back it will give <code>txt=134</code> then cursor should remain at 2 position with current code it always go to end. i.e. after 4.</p>