开发者

Android database overWriting same row over and over

I've been stuck on this for a few hours now. I have an Activity that calls a method to write some values into a database, it works, except for the fact that it overWrites the same row in the database over and over again. My database table does have an _id that is set to autoincrement.

try {
    myDataBase.beginTransaction();
    myDataBase.insert("camera_notes", null, camera_data);
    myDataBase.setTransactionSuccessful();
} catch (SQLException e) {
     Log.i(TAG,"#################Exception thrown from updateDataBaseNotes:################ "+e);
    e.printStackTrace();
}
finally{
    myDataBase.endTransaction();
}

close();

I have just tried adding the transaction code, but no luck so far. Does anyone have any ideas or can point me in the right direction?

Thanks

ContentValues camera_data开发者_开发知识库 = new ContentValues();
camera_data.put("note_title", title);
camera_data.put("note_text", note);
camera_data.put("image_source", image_src);
camera_data.put("sound_source", recording_src);


Is that the only row? If so, it sounds like you're destroying the entire table each time before you're inserting the row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜