我有一個android應用程序,當我點擊地圖上的一個標記時,它可以成功地將數據插入到我的數據庫中。SQLiteDatabase只在應用程序重新打開時更新
我有一個更新數據庫中的信息(列)的活動。它不會在我第一次嘗試時更新,但是當我關閉時,退出應用程序,再次運行並再次更新信息,它會成功更新,因此我相信我的代碼是正確的。問題是什麼?
過程:
月1日開放
位置標記
onInfoWindowClick開始新activityForResult
填補領域
保存(按鈕)
個返回值來更新行
不更新
重新打開
- 點擊已有標記時,填寫的字段,它更新時保存
- 當一個新的標記被放置時,填滿字段,不更新(意味着需要再次打開)
呼叫更新:
ContentValues cv = new ContentValues();
cv.put(LocationsDB.FIELD_TITLE, newReminder);
cv.put(LocationsDB.FIELD_MONTH, mm_final);
cv.put(LocationsDB.FIELD_DAY, dd_final);
cv.put(LocationsDB.FIELD_YEAR, yy_final);
getContentResolver().update(LocationsContentProvider.CONTENT_URI, cv, "lat=? AND lng=?", new String[] {location_lat, location_lng});
LocationContentProvider.java:
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs){
int count;
count = mLocationsDB.update(values, selection, selectionArgs);
return count;
}
LocationsDB.java:
public int update(ContentValues contentValues, String where, String[] whereArgs){
int cnt = mDB.update(DATABASE_TABLE, contentValues, where, whereArgs);
return cnt;
}
請顯示一些說明問題的代碼並且不超過必要的。 – 2014-10-20 00:33:42
你把更新功能放在哪裏? – 2014-10-20 00:39:52
@ m170897017將更新調用放置在onActivityResult() – 2014-10-20 00:44:15