Q:

Calling onPause as a regular function?

I have all of my code for updating sharedprefs in my onpause code. In my app onPause does nothing else but save. I want to update shared prefs when I move between activites. Is it ok to call onPause as my saving function instead of duplicating the code into a save() method?
Thank you for your help!

A:

Yes you can add it in OnPause() but its good approach add it some methods and call it in OnPause() in this way you can call save from other points too you will not limited.
void SavingCode() {

        // my Saving code here
    }

    @Override
    protected void onPause() {
        SavingCode();
        super.onPause();

    }

