i have an sqliteHelper that get data from table in database,i want to build an object from this class and read database but i get that error : "Couldn't read row 0, col -1 from CursorWindow,make sure cursor is initialized correctly android". this is my get function in sqliteHelper class:
public Vector<NoteTableItem> getAllNote() {
Vector<NoteTableItem> list = new Vector<NoteTableItem>();
SQLiteDatabase db = this.getWritableDatabase();
String selectQuery = "SELECT * FROM " + NOTE_TABLE_NAME ;
Cursor c = db.rawQuery(selectQuery, null);
//startManagingCursor(c);
c.moveToFirst();
if (c.getCount() > 0)
do {
NoteTableItem item = new NoteTableItem();
item.ID=c.getInt(c.getColumnIndex(KEY_ID));
item.title=c.getString(c.getColumnIndex(KEY_TITLE));
item.text=c.getString(c.getColumnIndex(KEY_TEXT));
item.photoAddress=c.getString(c.getColumnIndex(KEY_PHOTOADDRESS));
item.year=c.getInt(c.getColumnIndex(KEY_YEAR));
item.mounth=c.getInt(c.getColumnIndex(KEY_MOUNTH));
item.day=c.getInt(c.getColumnIndex(KEY_DAY));
item.hour=c.getInt(c.getColumnIndex(KEY_HOUR));
item.minute=c.getInt(c.getColumnIndex(KEY_MINUTE));
item.checked=c.getInt(c.getColumnIndex(KEY_CHECKED));
list.add(item);
} while (c.moveToNext());
db.close();
return list;
} i just want to create an object of this class.
Aucun commentaire:
Enregistrer un commentaire