while using onDestroy() method in saveInBackground() gives an error that is Cannot resolve method onDestroy() so below is my code for doing so
ParseRelation<ParseObject> p = ParseUser.getCurrentUser().getRelation("brkRelation");
ParseQuery p2 = p.getQuery();
List<ParseObject> oc = null;
try {
oc = p2.find();
for (ParseObject country2 : oc) {
if (country2 != null) {
country2.put("online", false);
country2.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
super.onDestroy();
} else {
Toast.makeText(getApplicationContext(), "Please Check your Internet Connection", Toast.LENGTH_LONG).show();
}
}
});
}
}
} catch (ParseException e1) {
e1.printStackTrace();
}
Before exiting my app I want to do save something in my db
gives me an error Cannot resolve method onDestroy()
As stated in the above answer, you are not in the escope of the Activity class.
The super refers to SaveCallback and not the Activity, you can simple do:
TheActivityName.super.onDestroy();
If you want to use the actual implementation in the class (not the super) you call TheActivityName.this.onDestroy(), or just onDestroy() cause the class is in escope (in this second case if you have a method named exactly as the outer class you want to refer to you need the Name.this)