Reputation: 716
First sorry for my bad English so I'll just ask my question.
I wrote my source
db.execSQL(String.format("DELETE FROM 'myTable' WHERE id=%d", i));
db.execSQL(String.format("UPDATE 'myTable' SET id=%d WHERE id=%d", i, i+1);
refreshList();
refreshList()
gets myTable table's rows and set ListAdapter to a ListView with new ArrayList<String>
.
but when it goes to refreshList function, it shows a previous database contents.
What seems to be the problem?
EDIT
This is the whole code what I written.
SQLiteDatabase db;
db = mHelper.getWritableDatabase();
db.execSQL(String.format("DELETE FROM '_CTGLIST' WHERE id=%d", i));
db.execSQL(String.format("UPDATE '_CTGLIST' SET id=%d WHERE id=%d", i, i+1));
db.close();
refreshList();
and
private void refreshList() {
ArrayList<String> mCategoryList = new ArrayList<String>;
SQLiteDatabase db;
Cursor cursor;
db = mHelper.getReadableDatabase();
cuCategory = db.rawQuery("SELECT * FROM '_CTGLIST' ORDER BY id ASC;", null);
while (cuCategory.moveToNext()) {
mCategoryList.add(cuCategory.getString(0));
}
db.close();
//and set list adapter here.
//i won't write this part of code in here.
}
Upvotes: 0
Views: 153
Reputation: 420
It looks like your query is executed first and not commited and then you are using a new connection in the refreshList method, so it will give you a result for the data that is commited and not the ones that are yet to be commited.
Upvotes: 1