android连接数据库时出现闪退现象

源码:
String sql= "select totalmoney from myaccount where username=?"; Cursor c = read.rawQuery(sql,new String[]{"dzy"}); if(c.moveToFirst()){ } else { AlertDialog.Builder diogal = new AlertDialog.Builder(account.this); final View view1 = LayoutInflater.from(account.this).inflate(R.layout.totalmoney_iteam,null); diogal.setView(view1); diogal.setTitle("总金额").setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { EditText money = (EditText)findViewById(R.id.totalmoney); String mon = money.getText().toString(); String sql = "insert into dzy (totalmoney)values(?)"; write.execSQL(sql,new String[]{mon}); } }).show(); }
logcat:04-16 06:28:07.236 5655-5655/? I/zygote: Not late-enabling -Xcheck:jni (already on) 04-16 06:28:07.287 5655-5655/? W/zygote: Unexpected CPU variant for X86 using defaults: x86 04-16 06:28:07.730 5655-5678/com.example.mathi.myapplication1 D/OpenGLRenderer: HWUI GL Pipeline 04-16 06:28:07.778 5655-5655/com.example.mathi.myapplication1 D/android.widget.GridLayout: vertical constraints: y3-y0>=1859, y3-y2<=238, y2-y1<=239, y1-y0<=239 are inconsistent; permanently removing: y3-y2<=238. 04-16 06:28:07.872 5655-5678/com.example.mathi.myapplication1 I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0 04-16 06:28:07.873 5655-5678/com.example.mathi.myapplication1 I/OpenGLRenderer: Initialized EGL, version 1.4 04-16 06:28:07.873 5655-5678/com.example.mathi.myapplication1 D/OpenGLRenderer: Swap behavior 1 04-16 06:28:07.874 5655-5678/com.example.mathi.myapplication1 W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 04-16 06:28:07.874 5655-5678/com.example.mathi.myapplication1 D/OpenGLRenderer: Swap behavior 0 04-16 06:28:07.928 5655-5678/com.example.mathi.myapplication1 D/EGL_emulation: eglCreateContext: 0xe8b8d920: maj 2 min 0 rcv 2 04-16 06:28:08.030 5655-5678/com.example.mathi.myapplication1 D/EGL_emulation: eglMakeCurrent: 0xe8b8d920: ver 2 0 (tinfo 0xe8b9b9f0) 04-16 06:28:08.099 5655-5678/com.example.mathi.myapplication1 D/EGL_emulation: eglMakeCurrent: 0xe8b8d920: ver 2 0 (tinfo 0xe8b9b9f0) 04-16 06:28:08.366 5655-5655/com.example.mathi.myapplication1 V/View: dispatchProvideAutofillStructure(): not laid out, ignoring 0 children of 1073741835 04-16 06:28:08.372 5655-5655/com.example.mathi.myapplication1 I/AssistStructure: Flattened final assist data: 3436 bytes, containing 1 windows, 13 views 04-16 06:28:18.269 5655-5661/com.example.mathi.myapplication1 I/zygote: Do partial code cache collection, code=24KB, data=30KB 04-16 06:28:18.269 5655-5661/com.example.mathi.myapplication1 I/zygote: After code cache collection, code=24KB, data=30KB 04-16 06:28:18.270 5655-5661/com.example.mathi.myapplication1 I/zygote: Increasing code cache capacity to 128KB 04-16 06:28:19.459 5655-5661/com.example.mathi.myapplication1 I/zygote: Do partial code cache collection, code=61KB, data=61KB 04-16 06:28:19.461 5655-5661/com.example.mathi.myapplication1 I/zygote: After code cache collection, code=61KB, data=61KB 04-16 06:28:19.461 5655-5661/com.example.mathi.myapplication1 I/zygote: Increasing code cache capacity to 256KB 04-16 06:28:21.850 5655-5661/com.example.mathi.myapplication1 I/zygote: Do full code cache collection, code=123KB, data=103KB 04-16 06:28:21.850 5655-5661/com.example.mathi.myapplication1 I/zygote: After code cache collection, code=121KB, data=79KB 04-16 06:28:21.892 5655-5678/com.example.mathi.myapplication1 D/EGL_emulation: eglMakeCurrent: 0xe8b8d920: ver 2 0 (tinfo 0xe8b9b9f0) 04-16 06:28:21.908 5655-5678/com.example.mathi.myapplication1 D/EGL_emulation: eglMakeCurrent: 0xe8b8d920: ver 2 0 (tinfo 0xe8b9b9f0) 04-16 06:28:21.942 5655-5655/com.example.mathi.myapplication1 E/SQLiteLog: (1) no such table: myaccount 04-16 06:28:21.943 5655-5655/com.example.mathi.myapplication1 D/AndroidRuntime: Shutting down VM 04-16 06:28:21.944 5655-5655/com.example.mathi.myapplication1 E/AndroidRuntime: FATAL EXCEPTION: main                                                                                 Process: com.example.mathi.myapplication1, PID: 5655                                                                                 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mathi.myapplication1/com.example.mathi.myapplication1.account}: android.database.sqlite.SQLiteException: no such table: myaccount (code 1): , while compiling: select totalmoney from myaccount where username=?                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)                                                                                     at android.app.ActivityThread.-wrap11(Unknown Source:0)                                                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)                                                                                     at android.os.Handler.dispatchMessage(Handler.java:106)                                                                                     at android.os.Looper.loop(Looper.java:164)                                                                                     at android.app.ActivityThread.main(ActivityThread.java:6494)                                                                                     at java.lang.reflect.Method.invoke(Native Method)                                                                                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)                                                                                  Caused by: android.database.sqlite.SQLiteException: no such table: myaccount (code 1): , while compiling: select totalmoney from myaccount where username=?                                                                                     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)                                                                                     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:890)                                                                                     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:501)                                                                                     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)                                                                                     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)                                                                                     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:1392)                                                                                     at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1331)                                                                                     at com.example.mathi.myapplication1.account.diolog(account.java:34)                                                                                     at com.example.mathi.myapplication1.account.onCreate(account.java:25)                                                                                     at android.app.Activity.performCreate(Activity.java:7009)                                                                                     at android.app.Activity.performCreate(Activity.java:7000)                                                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)                                                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)                                                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)                                                                                      at android.app.ActivityThread.-wrap11(Unknown Source:0)                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)                                                                                      at android.os.Handler.dispatchMessage(Handler.java:106)                                                                                      at android.os.Looper.loop(Looper.java:164)                                                                                      at android.app.ActivityThread.main(ActivityThread.java:6494)                                                                                      at java.lang.reflect.Method.invoke(Native Method)                                                                                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)  04-16 06:28:21.946 5655-5661/com.example.mathi.myapplication1 I/zygote: Do partial code cache collection, code=122KB, data=86KB 04-16 06:28:21.948 5655-5661/com.example.mathi.myapplication1 I/zygote: After code cache collection, code=122KB, data=86KB 04-16 06:28:21.948 5655-5661/com.example.mathi.myapplication1 I/zygote: Increasing code cache capacity to 512KB
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭