I created a simple code to change the image background on button click, but the problem is after changing the background image and closing the app and open it again the background image return to the default one, and I want to save the changed image background and display it for the next launch of my app.
here is my code:
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int bg = 0;
if (x[0] == 5) x[0] = 1;
if (x[0] == 1) bg = R.drawable.bg1;
if (x[0] == 2) bg = R.drawable.bg2;
if (x[0] == 3) bg = R.drawable.bg3;
if (x[0] == 4) bg = R.drawable.bg4;
if (x[0] == 5) bg = R.drawable.bg5;
layout.setBackgroundResource(bg);
x[0]++;
}
});