Method Ondestroy() Doesn't Work
When I run my app, all the checkboxes are checked in my ListView but I don't want them checked at the start. I think I didn't write onDestroy() correctly. Please help me! Here is
Solution 1:
onDestroy is not guaranteed to be called. Most of time it can be called if operating systems wants to shut down your application.
You can use onBackPressed or onPause instead
Solution 2:
I'm not sure about the way you handle the sharedpreference. This is how I usually do it. Change the onDestroy code to;
publicvoidonDestroy(){
super.onDestroy();
SharedPreferencesmyPrefs=this.getSharedPreferences("states", Context.MODE_PRIVATE);
SharedPreferences.Editor myEditor=myPrefs.edit();
myEditor.clear();
myEditor.commit();
}
Post a Comment for "Method Ondestroy() Doesn't Work"