本文整理匯總了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()));
}