How to append a comma to the end of strings when saving to a bundle?
<p>I have an activity that allows the user to pick a contact and it returns with the contact number and enter's it in a EditText.</p>

<p>Now the problem is, if the user enter's a number before they pick a contact the number will be gone when the activity is resumed.</p>

<p>I know i can user a bundle to save the state of the UI. The only problem is after the user enter's the number in the EditText i would like to add a comma to the end of the number automatically when the results are passed back in from the contact picker. </p>

<p>This is what i have so far..</p>

<pre><code>EditText numbers = null;
numbers = (EditText)findViewById(R.id.phoneNumbers);

@Override
protected void onRestoreInstanceState(Bundle outState){
    super.onResume();
    //opening my database
    mDbHelper.open();
    setRowIdFromIntent();
    //populating some fields 
    populateField();
</code></pre>

<p>Here is my onSavedInstanceState()...</p>

<pre><code> @Override
protected void onSaveInstanceState(Bundle outState){
    super.onSaveInstanceState(outState);
    if(mRowId != null){
    //Here just keeping a reference of a db ID i use
    outState.putLong(DbAdapter.KEY_ROWID, mRowId);
}
</code></pre>

<p>How would i save the edit text to the bundle and append a comma at the end?
Also is it possible to know when a user enters 10 digits and automatically append a (,) comma at the end?</p>

<p>EDIT:</p>

<p>Here is what i managed to come up with but it isnt working.</p>

<pre><code> @Override
protected void onSaveInstanceState(Bundle outState){
    super.onSaveInstanceState(outState);
    outState.putString("number", numbers.getText().toString().trim());
</code></pre>

<p>}</p>

<p>Then in onRestore()</p>

<pre><code>@Override
protected void onRestoreInstanceState(Bundle outState){
super.onResume();
mDbHelper.open();
if(currentNumber != null){
currentNumber = outState.getString("number").toString() + ",;
}
</code></pre>

<p>with this code it is just replacing the current number when the activity it resumed</p>
