私は次のように定義してデータベーステーブルを作成しています:-
public static final String Create_Database2= "CREATE TABLE " + Table_Name2 + "("
+ play20 + " INTEGER PRIMARY KEY, "
+ play1 + " LONG, "
+ play2 + " LONG, "
+ play3 + " INTEGER, "
+ play4 + " INTEGER, "
+ play5 + " LONG, "
+ play6 + " TEXT, "
+ play7 + " TEXT, "
+ play8 + " TEXT, "
+ play9 + " TEXT, "
+ play10 + " TEXT, "
+ play11 + " INTEGER, "
+ play12 + " INTEGER, "
+ play13 + " INTEGER, "
+ play14 + " INTEGER, "
+ play15 + " INTEGER, "
+ play16 + " INTEGER, "
+ play17 + " TEXT, "
+ play18 + " INTEGER, "
+ play19 + " TEXT"
+ ") ";
今、私はこのようにデータを取得しています:-
public Cursor getcontent()
{
Cursor d= database.query(DatabaseHandler.Table_Name2,allColumns,selection, null, null,null,null);
}
public String[] allColumns = { DatabaseHandler.play5, DatabaseHandler.play6,DatabaseHandler.play7,
DatabaseHandler.play8,DatabaseHandler.play9,DatabaseHandler.play10 };
String selection="playlist_id=100813";
上記が私のデータ選択の基準でした
Cursor r=X.getcontent();
if (r.getCount() > 0) {
r.moveToFirst();
do {
String id = r.getString(r.getColumnIndex("content_id"));
al.add(id);
String from_date =r.getString(r.getColumnIndex("from_date"));
String to_date =r.getString(r.getColumnIndex("to_date"));
String from_time =r.getString(r.getColumnIndex("from_time"));
String to_time =r.getString(r.getColumnIndex("to_time"));
String days =r.getString(r.getColumnIndex("days"));
String duration =r.getString(r.getColumnIndex("duration"));
} while (r.moveToNext()==true);
r.close();
} else {
Log.i("TAG"," No value found");
}
logcatでこのエラーが発生しています
02-22 15:37:04.565: E/AndroidRuntime(11544): FATAL EXCEPTION: main
02-22 15:37:04.565: E/AndroidRuntime(11544): java.lang.RuntimeException:
Unable to start activity ComponentInfo{com.example.webdata/com.example.webdata.MainActivity}:java.lang.IllegalStateException:
Couldnt read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
私はここで何を間違っていますか?