这是我的数据库列:你看到在最后一栏我把BLOB。
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_NAME + " (ID TEXT PRIMARY KEY,PASSWORD TEXT,FNAME TEXT,SNAME TEXT,BIRTHDATE TEXT,MATHGROUP TEXT,GENDER TEXT, PROFILEIMAGE BLOB)");
}
我要求用户从图库中选择一张图片。 图像保存在位图中。我有位图位图。 当我想插入数据时,我需要将位图转换为byte []。这样:
ByteArrayOutputStream stream1 = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream1);
byte [] buffer = stream1.toByteArray();
我插入数据。 (该方法在DatabaseHelper类中定义。)
boolean isInserted = myDb.insertData(editID.getText().toString(),
editPASSWORD.getText().toString(),
editFNAME.getText().toString(),
editSNAME.getText().toString(),
datePickerBIRTHDATE.getDayOfMonth() + "." + datePickerBIRTHDATE.getMonth() + "." + datePickerBIRTHDATE.getYear(),
spinnerMATHGROUP.getSelectedItem().toString(), spinnerGENDER.getSelectedItem().toString(), buffer );
我成功插入了。所以现在第一个用户就是sigen-up。但我现在不能做更多。如果用户输入ID并通过,我开始检查与他的详细信息匹配的数据详细信息,该应用程序失败(带注释)!我无法访问数据库信息。 问题是肯定的BLOB列(或我放入它使数据库崩溃)。我假设因为当我删除该列时,我对登录没有任何问题。 代码有什么问题吗?
这是Logcat
18:49:20 Gradle sync started
18:49:36 Gradle sync completed
18:49:38 Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
18:50:23 Gradle build finished in 44s 138ms
18:51:12 Throwable
Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
Details: Current thread: Thread[ApplicationImpl pooled thread 31,4,main] 1159879404
; dispatch thread: false; isDispatchThread(): false
SystemEventQueueThread: Thread[AWT-EventQueue-0 1.3#AI-141.2178183, eap:false,6,main] 393216142
18:52:23 Throwable
Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
Details: Current thread: Thread[ApplicationImpl pooled thread 31,4,main] 1159879404
; dispatch thread: false; isDispatchThread(): false
SystemEventQueueThread: Thread[AWT-EventQueue-0 1.3#AI-141.2178183, eap:false,6,main] 393216142
19:02:29 Executing tasks: [:app:assembleDebug]
19:02:35 Gradle build finished with 8 error(s) in 5s 814ms
19:03:41 Executing tasks: [:app:assembleDebug]
19:04:41 Gradle build finished in 59s 960ms
19:06:09 Executing tasks: [:app:assembleDebug]
19:06:11 Gradle build finished in 2s 559ms
19:08:10 Executing tasks: [:app:assembleDebug]
19:08:13 Gradle build finished in 3s 234ms
19:09:07 Executing tasks: [:app:assembleDebug]
19:09:10 Gradle build finished in 2s 520ms
19:11:03 Executing tasks: [:app:assembleDebug]
19:11:06 Gradle build finished in 2s 985ms
19:12:42 Executing tasks: [:app:assembleDebug]
19:12:44 Gradle build finished in 2s 67ms
19:15:39 Executing tasks: [:app:assembleDebug]
19:15:49 Gradle build finished in 10s 219ms
19:17:32 Executing tasks: [:app:assembleDebug]
19:17:41 Gradle build finished in 9s 521ms
19:18:14 Executing tasks: [:app:assembleDebug]
19:18:24 Gradle build finished in 9s 752ms
19:20:13 Executing tasks: [:app:assembleDebug]
19:20:23 Gradle build finished in 9s 445ms
20:02:46 Executing tasks: [:app:assembleDebug]
20:02:56 Gradle build finished in 10s 187ms
20:04:06 Executing tasks: [:app:assembleDebug]
20:04:17 Gradle build finished in 11s 160ms
20:04:45 Executing tasks: [:app:assembleDebug]
20:05:01 Gradle build finished in 15s 963ms
20:05:14 Executing tasks: [:app:assembleDebug]
20:05:24 Gradle build finished in 9s 832ms
20:06:17 Executing tasks: [:app:assembleDebug]
20:06:19 Gradle build finished in 2s 449ms
20:06:53 Executing tasks: [:app:assembleDebug]
20:06:56 Gradle build finished in 3s 202ms
20:09:25 Executing tasks: [:app:assembleDebug]
20:09:28 Gradle build finished in 2s 552ms