Reputation: 11187
In the app I'm working on I have a settings menu that needs to use functions like "saveSettings", "deleteSettings", etc. This is a flyout that lives in it's own activity. When the user presses a button the edit menu slides in. Currently I'm placing the save, dete, etc functions on every activity. This is inefficient, obviously, and will make maintenance difficult down the line if I need to make a change.
I created a new activity called userSettingsFunctions.java to store the references to the EditText and TextViews I need for the settings as well as the functions.
I would like to include that file on each activity in my app so the functions are available everywhere and if I need to do an update I can just edit one file instead of each activity in the app.
Is this possible? If so, can you point me in the right direction?
Upvotes: 0
Views: 76
Reputation: 2929
Try to Extend Class Application This class like a global content so u can use methods everywhere.
Upvotes: 0
Reputation: 4860
You need to create a baseActivity which handles with those methods and you need to extends this baseActivity instead of default Activity class, in this way you can have your settings function in every activity.
Upvotes: 2