Reputation: 59
I want to delete my data. I get "Student_ID" from my column consist of the ID at Parse. I am not sure where is the problem, the code had success one to two times when I tried, and with pressing the button multiple times. Maybe because it need to wait for the request from my database parse? I think the problem is at the for loop, it seem to stucks there. Can anyone fix it?
public void deleteStudent(){
ParseQuery<ParseObject> query=ParseQuery.getQuery("Student");
query.whereEqualTo("Student_ID",ID);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if(e==null) {
for (ParseObject delete : parseObjects) {
delete.deleteInBackground();
Toast.makeText(getApplicationContext(), "deleted", Toast.LENGTH_SHORT).show();
}
}else{
Toast.makeText(getApplicationContext(), "error in deleting", Toast.LENGTH_SHORT).show();
}
}
});
}
Upvotes: 1
Views: 2982
Reputation: 1103
parse dose have an api to bulk delete, so save a for loop
ParseObject.deleteAllInBackground
Upvotes: 0