ContentValues不会将值插入表中

时间:2015-12-13 23:18:59

标签: java android sqlite

我有这个:

-std=c++11

作为我的add方法,正如我追踪它,成功添加了记录。但当我尝试使用下面的代码获取我的注释时, public void addNewNote(Note n) { ContentValues values = new ContentValues(); values.put(COLUMN_TITLE, n.getNote_title()); values.put(COLUMN_TEXT, n.getNote_text()); values.put(COLUMN_FK, n.getNote_ForeignKey()); //this column is integer type values.put(COLUMN_PT, String.valueOf(n.getNote_PersonType())); //this column is char type SQLiteDatabase db = this.getWritableDatabase(); db.insert("tbl_Notes",null, values); } 始终返回null,findNote始终为0.

cnt

这是我的public Note findNote(int note_id){ String query = "select * from tbl_Notes"; // where " + COLUMN_ID + " = " + note_id; SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(query, null); int cnt = cursor.getCount(); Note N = new Note(); if (cursor.moveToFirst()) { cursor.moveToFirst(); N.setNote_title(cursor.getString(1)); //title column N.setNote_text(cursor.getString(2)); //text body column N.setNote_ForeignKey(Integer.parseInt(cursor.getString(3))); //foreign key column N.setNote_PersonType(cursor.getString(4).charAt(0)); //person type column cursor.close(); }else { N = null; } return N; } ,它会触发onClick

addNewNote

我做错了什么?!

0 个答案:

没有答案