Android 游标未正确初始化?

Android 游标未正确初始化?,android,android-sqlite,Android,Android Sqlite,我通过定义以下内容来创建数据库表:- public static final String Create_Database2= "CREATE TABLE " + Table_Name2 + "(" + play20 + " INTEGER PRIMARY KEY, " + play1 + " LONG, " + play2 + " LONG, " + play3

我通过定义以下内容来创建数据库表:-

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.

我做错了什么?

检查条件ifr.moveToFirst the go forward

你能检查getcontent是否没有返回null吗?是的,它没有返回null我已经检查过了,所以我认为它很清楚。。尝试在database.query方法中传递正确的参数;完成所有处理后,将从光标完成所有处理。在日志语句后的最后一行写出来。