當前位置: 首頁>>代碼示例>>Java>>正文


Java DataSupport.delete方法代碼示例

本文整理匯總了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()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DeleteTest.java

示例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());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:DeleteTest.java

示例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);
}
 
開發者ID:yuukidach,項目名稱:Ucount,代碼行數:18,代碼來源:IOItemAdapter.java

示例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);
    }
 
開發者ID:LynnYuki,項目名稱:CoolCloud-Weather,代碼行數:27,代碼來源:ChooseAreaActivity.java

示例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();
}
 
開發者ID:SirLYC,項目名稱:Android-Gank-Share,代碼行數:15,代碼來源:CollectFragment.java

示例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);
}
 
開發者ID:blxble,項目名稱:mesh-core-on-android,代碼行數:21,代碼來源:FolderAdapter.java

示例7: testDeleteWithNotExistsRecordById

import org.litepal.crud.DataSupport; //導入方法依賴的package包/類
public void testDeleteWithNotExistsRecordById() {
	int rowsAffected = DataSupport.delete(Student.class, 998909);
	assertEquals(0, rowsAffected);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:5,代碼來源:DeleteTest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:DeleteTest.java

示例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()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:DeleteTest.java

示例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()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:DeleteTest.java


注:本文中的org.litepal.crud.DataSupport.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。