通过objectId删除数据,单个条件测试成功。
private void deleteClass(int classId) {
BmobQuery<ClassTable> query = new BmobQuery<>();
query.addWhereEqualTo("classId",classId);
query.findObjects(new FindListener<ClassTable>() {
@Override
public void done(List<ClassTable> list, BmobException e) {
if (e == null){
if (list.size() >0){
//课程号存在,则删除课程
ClassTable classTable = new ClassTable();
classTable.delete(list.get(0).getObjectId(), new UpdateListener() {
@Override
public void done(BmobException e) {
if (e == null) {
Toast.makeText(getActivity(),"删除成功。",Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getActivity(),"删除失败。",Toast.LENGTH_SHORT).show();
}
}
});
}else {
//课程号不存在
Toast.makeText(getActivity(),"该课程号不存在。",Toast.LENGTH_SHORT).show();
}
}else {
//查询失败
}
}
});
}