本文整理汇总了Java中org.litepal.crud.DataSupport.delete方法的典型用法代码示例。如果您正苦于以下问题:Java DataSupport.delete方法的具体用法?Java DataSupport.delete怎么用?Java DataSupport.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.crud.DataSupport
的用法示例。
在下文中一共展示了DataSupport.delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteCascadeO2OAssociationsById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteCascadeO2OAssociationsById() {
createStudentsTeachersWithIdCard();
int affectedRows = DataSupport.delete(Student.class, jude.getId());
assertEquals(2, affectedRows);
assertNull(getStudent(jude.getId()));
assertNull(getIdCard(judeCard.getId()));
affectedRows = DataSupport.delete(IdCard.class, roseCard.getId());
assertEquals(2, affectedRows);
assertNull(getStudent(rose.getId()));
assertNull(getIdCard(roseCard.getId()));
affectedRows = DataSupport.delete(Teacher.class, john.getId());
assertEquals(2, affectedRows);
assertNull(getTeacher(john.getId()));
assertNull(getIdCard(johnCard.getId()));
affectedRows = DataSupport.delete(IdCard.class, mikeCard.getId());
assertEquals(1, affectedRows);
assertNull(getIdCard(mikeCard.getId()));
}
示例2: testDeleteCascadeM2MAssociationsById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteCascadeM2MAssociationsById() {
createStudentsTeachersWithAssociations();
int rowsAffected = DataSupport.delete(Teacher.class, john.getId());
assertEquals(2, rowsAffected);
assertNull(getTeacher(john.getId()));
assertM2MFalse(studentTable, teacherTable, rose.getId(), john.getId());
assertM2M(studentTable, teacherTable, rose.getId(), mike.getId());
assertM2M(studentTable, teacherTable, jude.getId(), mike.getId());
createStudentsTeachersWithAssociations();
rowsAffected = DataSupport.delete(Teacher.class, mike.getId());
assertEquals(3, rowsAffected);
assertNull(getTeacher(mike.getId()));
assertM2MFalse(studentTable, teacherTable, rose.getId(), mike.getId());
assertM2MFalse(studentTable, teacherTable, jude.getId(), mike.getId());
assertM2M(studentTable, teacherTable, rose.getId(), john.getId());
}
示例3: removeItem
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void removeItem(int position) {
IOItem ioItem = mIOItemList.get(position);
Sum sum = DataSupport.find(Sum.class, 1); // 1 代表sum;
Sum month;
int type = ioItem.getType();
sum.setTotal(sum.getTotal()-ioItem.getMoney() * type);
sum.save();
// 判断收支类型
if (type < 0) month = DataSupport.find(Sum.class, 2); // 2 代表cost
else month = DataSupport.find(Sum.class, 3); // 3 代表earn
month.setTotal(month.getTotal()-ioItem.getMoney());
month.save();
DataSupport.delete(IOItem.class, mIOItemList.get(position).getId());
mIOItemList.remove(position);
notifyItemRemoved(position);
}
示例4: onContextItemSelected
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public boolean onContextItemSelected(MenuItem item){
switch (item.getItemId()){
case 0:
//从数据库查询数据id放入list数组
List<CityRecond> list = DataSupport.select("id").find(CityRecond.class);
for (CityRecond recond:list){
delerecondList.add(recond.getId());
}
//删除listview之中item对应id的数据
DataSupport.delete(CityRecond.class, delerecondList.get(selectPosition));
recondList.remove(selectPosition);
recondAdapter.notifyDataSetChanged();
listViewRecond.setSelection(0);
Log.d("TAG","删除数据是"+delerecondList.get(selectPosition));
Log.d("TAG0","删除的位置是"+selectPosition);
showShort("删除成功");
return true;
default:
}
return super.onContextItemSelected(item);
}
示例5: removeSelectedItems
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
private void removeSelectedItems(){
List<CollectItem> selectItems = new ArrayList<>();
for (Integer pos : posSet) {
selectItems.add(mItemList.get(pos));
}
for (CollectItem item : selectItems) {
DataSupport.delete(CollectItem.class, item.id);
mItemList.remove(item);
}
if(isSelectAll){
showEmptyView(true);
}
endSelect();
}
示例6: onMerged
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
/**
* 合并数据处理
*
* @param selectedPosition
* @param targetPosition
*/
@Override
protected void onMerged(int selectedPosition, int targetPosition) {
List<DeviceNode> deviceNodeList = mData.get(targetPosition).getDeviceNodeList();
DeviceNode deviceNode = mData.get(selectedPosition).getDeviceNodeList().get(0);
if (deviceNodeList.size() == MockFolderAdapter.ITEM_SINGLE_DEVICE) {
mData.get(targetPosition).setGroupName(deviceNode.getName());
}
deviceNodeList.add(deviceNode);
mData.get(targetPosition).setDeviceNodeList(deviceNodeList);
mData.get(targetPosition).isGroup = true;
mData.get(targetPosition).save();
DataSupport.delete(DeviceNodeGroup.class, mData.get(selectedPosition).getId());
mData.remove(selectedPosition);
}
示例7: testDeleteWithNotExistsRecordById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteWithNotExistsRecordById() {
int rowsAffected = DataSupport.delete(Student.class, 998909);
assertEquals(0, rowsAffected);
}
示例8: testDeleteById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteById() {
initJude();
jude.save();
int rowsAffected = DataSupport.delete(Student.class, jude.getId());
assertEquals(1, rowsAffected);
Student s = getStudent(jude.getId());
assertNull(s);
}
示例9: testDeleteCascadeM2OAssociationsOnMSideById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteCascadeM2OAssociationsOnMSideById() {
createClassroomStudentsTeachers();
int rowsAffected = DataSupport.delete(Classroom.class, gameRoom.get_id());
assertEquals(5, rowsAffected);
assertNull(getClassroom(gameRoom.get_id()));
assertNull(getStudent(jude.getId()));
assertNull(getStudent(rose.getId()));
assertNull(getTeacher(john.getId()));
assertNull(getTeacher(mike.getId()));
}
示例10: testDeleteCascadeM2OAssociationsOnOSideById
import org.litepal.crud.DataSupport; //导入方法依赖的package包/类
public void testDeleteCascadeM2OAssociationsOnOSideById() {
createClassroomStudentsTeachers();
int rowsAffected = DataSupport.delete(Student.class, jude.getId());
assertEquals(1, rowsAffected);
assertNull(getStudent(jude.getId()));
rowsAffected = DataSupport.delete(Student.class, rose.getId());
assertEquals(1, rowsAffected);
assertNull(getStudent(rose.getId()));
rowsAffected = DataSupport.delete(Teacher.class, john.getId());
assertEquals(1, rowsAffected);
assertNull(getTeacher(john.getId()));
rowsAffected = DataSupport.delete(Teacher.class, mike.getId());
assertEquals(1, rowsAffected);
assertNull(getTeacher(mike.getId()));
}