Ok guys, I can use shared preferences to save text so next time the app is loaded that text is displayed/restored
But is there a way to do this with Button Background Images?
Ok guys, I can use shared preferences to save text so next time the app is loaded that text is displayed/restored
But is there a way to do this with Button Background Images?
Don't know what exactly you wan't to do, but you can obviously save an image(Bitmap) as a byte array. Also you can compress it using Bitmap's compress method. This can be of some help if you are sure about using shared prefs for saving image.
ImageView iv = (ImageView) findViewById(R.id.imageView);
Intent intent = getIntent();
Boolean changeImageBg = intent.getBooleanExtra("change", false);
if (changeImageBg) {
iv.setImageResource(R.drawable.arrow_up_left_2small);
SharedPreferences sharedpreferences = getSharedPreferences("done", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
String string;
string = "arrow_up_left_2small";
editor.putString("aul", string);
editor.commit();
Ok, so above is the saving side. Since my image is part of the app I was able to save it easily once I understood what to do. I will be using boolean to trigger differnt images based on the active boolean I will be able to trigger the save for the appropriate image, I will at some point look at passing this code over the app so I can use less code.
SharedPreferences prefs = this.getSharedPreferences("done", Context.MODE_PRIVATE);
String imageName = prefs.getString("aul", "");
int resID = getResources().getIdentifier(imageName, "drawable", getPackageName());
ImageView image = (ImageView) findViewById(R.id.imageView);
image.setImageResource(resID);
}
Here is where I call the file path and use it on create to re apply the pictures