简体   繁体   English

我在 android 上开发一个应用程序,每次单击按钮时都会处理 sqlitedatabase 我的应用程序停止这是 logcat 消息和代码

[英]am developping an app on android handling sqlitedatabase every time I click on a button my app stops this is the logcat msg and the code

2021-11-18 20:16:12.067 21990-21990/com.example.db1 D/AndroidRuntime: Shutting down VM
2021-11-18 20:16:12.069 21990-21990/com.example.db1 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.db1, PID: 21990
    java.lang.IllegalStateException: Could not execute method for android:onClick
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
        at android.view.View.performClick(View.java:7352)
        at android.widget.TextView.performClick(TextView.java:14230)
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119)
        at android.view.View.performClickInternal(View.java:7318)
        at android.view.View.access$3200(View.java:846)
        at android.view.View$PerformClick.run(View.java:27800)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7050)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
        at android.view.View.performClick(View.java:7352) 
        at android.widget.TextView.performClick(TextView.java:14230) 
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) 
        at android.view.View.performClickInternal(View.java:7318) 
        at android.view.View.access$3200(View.java:846) 
        at android.view.View$PerformClick.run(View.java:27800) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7050) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965) 
     Caused by: android.database.sqlite.SQLiteException: near "table": syntax error (code 1 SQLITE_ERROR[1]): , while compiling: SELECT _id, data FROM table
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1229)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:703)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1865)
        at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1712)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1583)
        at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1751)
        at com.example.db1.MyDbAdapter.getData(MyDbAdapter.java:27)
        at com.example.db1.MainActivity.show(MainActivity.java:34)
        at java.lang.reflect.Method.invoke(Native Method) 
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) 
        at android.view.View.performClick(View.java:7352) 
        at android.widget.TextView.performClick(TextView.java:14230) 
        at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) 
        at android.view.View.performClickInternal(View.java:7318) 
        at android.view.View.access$3200(View.java:846) 
        at android.view.View$PerformClick.run(View.java:27800) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7050) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965) 

Caused by: android.database.sqlite.SQLiteException: near "table": syntax error (code 1 SQLITE_ERROR[1]): , while compiling: SELECT _id, data FROM table See this?Something wrong in your sql. Caused by: android.database.sqlite.SQLiteException: near "table": syntax error (code 1 SQLITE_ERROR[1]): , while compiling: SELECT _id, data FROM table See this?Something wrong in your sql.

And look at here:看看这里:

   at com.example.db1.MyDbAdapter.getData(MyDbAdapter.java:27)
    at com.example.db1.MainActivity.show(MainActivity.java:34)

check these two lines,something wrong here检查这两行,这里有问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每当我单击“后退/主页”按钮时,代码的asynctask部分就会关闭/停止应用 - The asynctask part of my code closes/stops the app whenever I click the back/home button 每次我单击登录按钮时,应用程序都会崩溃 - App keeps crashing every time i click the Log in Button 我的Android应用程式每次执行时都会当机 - My Android app crashes every time I run it 当我第二次单击按钮时,App android崩溃 - App android crashes when i click button in second time 当我单击运行按钮时,应用程序停止运行并出现错误 - Android 应用程序 - When I Click the Run Button, Apps Stops running with an error- Android App 我正在使用 firebase UI 登录到我的应用程序,但是当我使用 Facebook 构建器时,它会停止应用程序如何为该按钮充气..? - I am using firebase UI login into my app but when i use Facebook builder it stops the app how to inflate that button..? 如何在 Android 应用程序中获取 logcat -v 时间? - How to get logcat -v time in an Android App? Android Studio-每次单击按钮时如何在线性布局上生成新的textview - Android Studio - How can I generate a new textview on my linear layout every time i click a button 当我第二次按下按钮时,应用程序停止工作 - When I press second time on the button , the app stops working 我的android应用“意外停止” - My android app “stops unexpectedly”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM