我有一个listView,其中包含笔记制作应用程序的注释标题。我正在尝试实现itemclicklistener来打开相应的注释。 这是SQLite表创建代码:
public static final String TABLE_NAME = "notes";
public static final String KEY_ID = "_id";
public static final String DATA = "data";
public static final String TITLE = "title";
String CREATE_TABLE = "create table " + TABLE_NAME + "(" + KEY_ID + " integer primary key autoincrement,"
+ DATA + " text not null,"
+ TITLE + " text not null"
+ " ) ; ";
以下是获取数据的代码:
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Cursor cursor = (Cursor) mListView.getItemAtPosition(position);
String data = (cursor.getString(2));
问题是当我将1传递给cursor.getString(1)方法时,我得到了标题,而我应该在将2传递给同一个数据时获取数据,抛出游标初始化错误。