Question: So I am currently using the following method to save text to my `SharedPreferences SM`:

```
implementingacency.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasfocus) {
                if(!hasfocus){
                    EditText et = (EditText) v;
                    if(et.getText().toString().length()>0)
                        SM.set_value(SharePrefForproject.KEY_implementationagency, et.getText().toString());
                }
            }
        });

```

Here, the `implementingagency` is an `editText`. The problem I am having on save is that in some if the `editTexts` the `onFocusChangeListener` is not called and hence data is not saved. Can anyone recommend me another method to save data from editText ?

Answer: 
One option would be to use a [TextWatcher](http://developer.android.com/reference/android/text/TextWatcher.html) and save the data as the user types it.

```
    implementingacency.addTextWatcher(new TextWatcher() {
            @Override
            public void afterTextChanged(Editable s) {
                    SM.set_value(SharePrefForproject.KEY_implementationagency, s.toString());
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }
    });

```
The `setOnPageChangeListener()` is ViewPager method

```
mViewPager.setOnPageChangeListener(this);

```

This is an example [ViewPager](http://developer.android.com/reference/android/support/v4/view/ViewPager.html)

Choose the event you think is suitable for your app 

```
onPageScrollStateChanged(int state)
onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
onPageSelected(int position)

```

[Here is the `setOnPageChangeListener()` docs](http://developer.android.com/reference/android/support/v4/view/ViewPager.SimpleOnPageChangeListener.html)