这是事情:
我有一个DBAdapter类,MakeListActivity和SeeListActivity.
在DBAdapter中我做了以下方法:
public Cursor commitquery(String query){ return myDataBase.rawquery(query,null);}
MakeListActivity具有以下方法:
String query = "INSERT INTO List('name','description') VALUES('"+name+"','"+desc+"')";dbAdapter.commitquery(query);
最后,SeeListActivity具有以下代码:
Cursor c = dbAdapter.commitquery("SELECT * FROM List");if(c!=null){ c.movetoFirst(); Log.i("cursor",c.getString(1));}
我实际上不确定我是否正确插入数据,但是当我想查看数据时(在我的情况下用logcat记录它)我得到“不幸的是,com.dstankovic.app已经停止了”.
这里也是logcat错误:
02-26 00:31:11.762: E/AndroIDRuntime(660): java.lang.IllegalStateException: Could not execute method of the activity02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.vIEw.VIEw.onClick(VIEw.java:3599)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.vIEw.VIEw.performClick(VIEw.java:4204)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.vIEw.VIEw$PerformClick.run(VIEw.java:17355)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.os.Handler.handleCallback(Handler.java:725)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.os.Handler.dispatchMessage(Handler.java:92)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.os.Looper.loop(Looper.java:137)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.app.ActivityThread.main(ActivityThread.java:5041)02-26 00:31:11.762: E/AndroIDRuntime(660): at java.lang.reflect.Method.invokeNative(Native Method)02-26 00:31:11.762: E/AndroIDRuntime(660): at java.lang.reflect.Method.invoke(Method.java:511)02-26 00:31:11.762: E/AndroIDRuntime(660): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)02-26 00:31:11.762: E/AndroIDRuntime(660): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:560)02-26 00:31:11.762: E/AndroIDRuntime(660): at dalvik.system.NativeStart.main(Native Method)02-26 00:31:11.762: E/AndroIDRuntime(660): Caused by: java.lang.reflect.InvocationTargetException02-26 00:31:11.762: E/AndroIDRuntime(660): at java.lang.reflect.Method.invokeNative(Native Method)02-26 00:31:11.762: E/AndroIDRuntime(660): at java.lang.reflect.Method.invoke(Method.java:511)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.vIEw.VIEw.onClick(VIEw.java:3594)02-26 00:31:11.762: E/AndroIDRuntime(660): ... 11 more02-26 00:31:11.762: E/AndroIDRuntime(660): Caused by: androID.database.Cursorindexoutofboundsexception: Index 0 requested,with a size of 002-26 00:31:11.762: E/AndroIDRuntime(660): at androID.database.AbstractCursor.checkposition(AbstractCursor.java:424)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.database.AbstractwindowedCursor.checkposition(AbstractwindowedCursor.java:136)02-26 00:31:11.762: E/AndroIDRuntime(660): at androID.database.AbstractwindowedCursor.getString(AbstractwindowedCursor.java:50)02-26 00:31:11.762: E/AndroIDRuntime(660): at com.dulerock.eatwell.MakeNewListActivity.SaveList(MakeNewListActivity.java:278)
有人可以给我一个暗示吗?
提前致谢
如果游标中有数据,则movetoFirst()返回true,如果为空,则返回false
试试这个
Cursor c = dbAdapter.commitquery("SELECT * FROM List");if(c.movetoFirst()){ Log.i("cursor",c.getString(1));}总结
以上是内存溢出为你收集整理的Android rawQuery结果检查全部内容,希望文章能够帮你解决Android rawQuery结果检查所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)