【发布时间】:2010-07-15 23:18:20
【问题描述】:
private void datafill()
{
Cursor notesCursor = mDbHelper.fetchAllNotes();
startManagingCursor(notesCursor);
/* JournalRowId is the row id from the first database containing all journal names
All notes are kept in database 2. I want only the notes that correspond to each
journal to be listed, KEY_HOMEID is the non visible field that shows where
each note came from.
*
*/
if (editjournalDbAdapter.KEY_HOMEID == journalRowId){
String[] from = new String[]{editjournalDbAdapter.KEY_HEIGHT};
int[] to = new int[]{R.id.detail1};
}
//Error here "from" and "to" are not defined outside of if statement
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.journaldetailrow, notesCursor, from, to);
setListAdapter(notes);
}
【问题讨论】:
-
我在上面遇到了一个错误。即使我在 IF 之前定义了变量。是否可以使用上面的代码?...(如果记录不对应则跳过的if语句)
标签: java android sqlite cursor