Cursor cursor=myDatabase.rawQuery("select ids,title,times from goodtime" , null);
cursor.moveToFirst();
while(!cursor.isAfterLast()){
int id=cursor.getInt(cursor.getColumnIndex("ids"));
String title=cursor.getString(cursor.getColumnIndex("title"));
String times=cursor.getString(cursor.getColumnIndex("times"));
System.out.println(title);
System.out.println(cursor.getColumnIndex("bj"));
String beijing=cursor.getString(cursor.getColumnIndex("bj"));
上面是我的代码,title还是可以正常查找的,但是bj这个变量的值确实-1,同时报出错误
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.notebook/com.example.notebook.Notebook}: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
这是我创建的表:
String ml="create table goodtime(ids integer PRIMARY KEY autoincrement,title text,content text,times text,ptpath text,mppath text,vdpath text,islock integer,password text,bj text)";
arg0.execSQL(ml);
网上说有可能大小写不对,我仔细查看了变量名都是一致的啊
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。