我有一个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