With the below code i am replacing the all characters(if my edittext contains four a's all a's are removed here) that contains substring and the cursor position is goes to before first character in edittext field.
//getting cursor position
int end = t1.getSelectionEnd();
//getting the selected Text
String selectedStr = t1.getText().toString().substring(end-1, end);
//replacing the selected text with empty String and setting it to EditText
t1.setText(t1.getText().toString().replace(selectedStr, ""));
How can i clear the single character before the cursor position(if my cursor is middle of the edittext) without changing the cursor position.
I solved with this function: