최근에 나는 HTC Desire 시리즈에 대해 많은 불만을 겪었으며 SQL 문을 호출하는 동안 오류가 발생했습니다. 다음을 포함하는 로그 스냅 샷이있는 사용자로부터 보고서를 받았습니다. Sqlite가 HTC Desire HD 문제를 일으켰습니다.
I/Database(2348): sqlite returned: error code = 8, msg = statement aborts at 1: [pragma journal_mode = WAL;]
E/Database(2348): sqlite3_exec to set journal_mode of /data/data/my.app.package/files/localized_db_en_uk-1.sqlite to WAL failed
호출이 커서가 열려 것으로 자체 명단 심각한 런타임 오류의 데이터베이스 결과를 열 수 있기 때문에 내 응용 프로그램은 기본적으로 화염에 불타는 하였다. 커서를 열려고 시도 할 때 커서가 없어야합니다.
이것은 HTC Desire HD 및 Z에서만 발생합니다. 기본적으로 내 코드는 다음을 수행합니다 (문제 영역을 분리하기 위해 약간 변경됨).
SQLiteDatabase db;
String dbName;
public SQLiteDatabase loadDb(Context context) throws IOException{
//Close any old db handle
if (db != null && db.isOpen()) {
db.close();
}
// The name of the database to use from the bundled assets.
String dbAsset = "/asset_dir/"+dbName+".sqlite";
InputStream myInput = context.getAssets().open(dbAsset, Context.MODE_PRIVATE);
// Create a file in the app's file directory since sqlite requires a path
// Not ideal but we will copy the file out of our bundled assets and open it
// it in another location.
FileOutputStream myOutput = context.openFileOutput(dbName, Context.MODE_PRIVATE);
byte[] buffer = new byte[1024];
int length;
while ((length = myInput.read(buffer)) > 0) {
myOutput.write(buffer, 0, length);
}
// Close the streams
myOutput.flush();
// Guarantee Write!
myOutput.getFD().sync();
myOutput.close();
myInput.close();
// Not grab the newly written file
File fileObj = context.getFileStreamPath(dbName);
// and open the database
return db = SQLiteDatabase.openDatabase(fileObj.getAbsolutePath(), null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
}
슬프게도이 휴대 전화는 영국에서만 사용 가능하며 인벤토리에없는 휴대 전화입니다. HTC Desire 시리즈에서만이 유형의 보고서를 받고 있습니다. 이 코드가 아무런 문제없이 작동하면서 변경된 사항을 알 수 없습니다. 제가 누락 된 것이 있습니까?
나는 그것이 가치가있는 것처럼 들린다, 나는 내일 이것을 명확히 시험 할 것이다. 작동하면 체크 박스와 맥주가 생깁니다. –
기니아 피그를 찾아 냈습니다. 감사! 그것은 동시에 굉장하고 슬 was습니다. –
@ 그렉 : "it worked"... 'SQLiteDatabase.OPEN_READONLY'을 (를) 제거하고 있습니까? 앞으로 호환성 문제를 막을 수 있도록 호환성 테스트 스위트의 차이점을 알려 주시기 바랍니다. 감사! – CommonsWare