-1
從sqlite數據庫刪除後有空行,並將下一行數據記錄到空行後的下一行。如何解決這個問題?在我刪除一些瘦所有工作正確之前,但刪除後,我有這個問題。從sqlite數據庫刪除後有一個空行
private static final String DB_CREATE =
"create table " + DB_TABLE + "(" +
COLUMN_ID + " integer primary key autoincrement, " +
COLUMN_NAME + " text, " +
COLUMN_TIME + " text, " +
COLUMN_RAW_TIME + " integer " +
");";
用於刪除我使用:
//method which called delRec from DB class
public boolean onContextItemSelected(MenuItem item) {
if (item.getItemId() == CM_DELETE_ID) {
AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item
.getMenuInfo();
db.delRec(acmi.id);
getSupportLoaderManager().getLoader(0).forceLoad();
}
else if (item.getItemId() == RESET_STOPWATCH){
AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) item
.getMenuInfo();
db.resetTime(Long.toString(acmi.id));
getSupportLoaderManager().getLoader(0).forceLoad();
}
return super.onContextItemSelected(item);
}
// delete
public void delRec(long id) {
//mDB.delete(DB_TABLE, COLUMN_ID + " = " + id, null);
mDB.execSQL("DELETE FROM mytab WHERE _id = " + id);
}
用於添加:
public void addRec(String txt, String txt2, long time) {
ContentValues cv = new ContentValues();
cv.put(COLUMN_TIME, txt2);
cv.put(COLUMN_NAME, txt);
cv.put(COLUMN_RAW_TIME, time);
mDB.insert(DB_TABLE, null, cv);
考慮在問題中添加一些細節,例如代碼。 – laalto
準確地寫下你想要刪除的代碼和你得到的空白行。 – ved
提供一些代碼 – Piyush