0

I am working on my application and I want to change the color of their UI with the click of button.....Like this....

Button change=findViewById(R.id.change_UI);
 change.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
           //My code to change the color of UI
           //like blue to green-red-black etc (randomly)
        }

The above things are working fine but when I again restart my application all things were same as I open it first time...with blue color UI.

I am new for development and i know this question is not so much interested but please help to solve this problem.

Dhanshri
  • 730
  • 6
  • 19
Vipul Chauhan
  • 383
  • 2
  • 15

2 Answers2

0

You should use SharedPreferences for this case. There is no problem for using it when you have more than 1 variable so don't worry.

Here is link to another answer how to use it properly: Android Shared preferences example

Another option could be creating one object which will hold all settings data and save it to a file and read it with every app run but for your case it would be overkill.

EDIT: SharedPreferences data are stored in an XML file, a good practice would be not to store there more than 100kb. If you want to store something bigger you SQL database like Room or save yout data to file.

More information you can find here: Shared Preferences "limit" or in this answer https://stackoverflow.com/a/30638736/6329985

DawidJ
  • 1,159
  • 11
  • 19
0

You can setup a preference activity as in here.

nazaif
  • 53
  • 8