Stackoverflow 上有很多开放线程(除了没有线程之外的所有线程都给了我正确的答案来解决这个问题)。
在各种操作系统 2.3.6、4.0.3 上出现此错误(因此绝对与 Android 操作系统版本无关)
场景一:应用程序版本 2.0 在市场上可供用户下载
第 1 步 -用户下载应用程序并且没有错误。
场景二:应用程序版本 2.0 在市场上可供用户下载
第 1 步 -用户已经拥有应用程序 1.5 的先前版本(市场要求用户更新,用户执行更新)。市场卸载并安装新版本,系统在应用程序启动时崩溃并出现以下错误..
I/Database(31396): sqlite returned: error code = 14, msg = cannot open file at line 27205 of [42537b6056]
E/Database(31396): sqlite3_open_v2("/data/data/com.XXXXX.XXXXX/databases/XXX", &handle, 2, NULL) failed
W/b (31396): could not open database XXX - unable to open database file
W/b (31396): copying database from assets...
W/b (31396): extracting file: 'XXX'...
E/b (31396): Couldn't open XXX for writing (will try read-only):
E/b (31396): com.a.a.a: Missing databases/XXX.zip file in assets or target folder not writable
E/b (31396): at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
E/b (31396): at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
E/b (31396): at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
E/b (31396): at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
E/b (31396): at java.io.FileOutputStream.<init>(FileOutputStream.java:144)
E/b (31396): at com.a.a.b.b(Unknown Source)
E/b (31396): at com.a.a.b.a(Unknown Source)
E/b (31396): at com.a.a.b.getWritableDatabase(Unknown Source)
E/b (31396): at com.a.a.b.getReadableDatabase(Unknown Source)
E/b (31396): at com.XXXXX.XXXXX.x.a(Unknown Source)
E/b (31396): at com.XXXXX.XXXXX.ay.a(Unknown Source)
E/b (31396): at com.XXXXX.XXXXX.ay.doInBackground(Unknown Source)
E/b (31396): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/b (31396): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
E/b (31396): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
E/b (31396): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
E/b (31396): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
E/b (31396): at java.lang.Thread.run(Thread.java:1019)
I/Database(31396): sqlite returned: error code = 14, msg = cannot open file at line 27205 of [42537b6056]
E/Database(31396): sqlite3_open_v2("/data/data/com.XXXXX.XXXXX/databases/XXX", &handle, 1, NULL) failed
W/System.err(31396): android.database.sqlite.SQLiteException: unable to open database file
W/System.err(31396): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
W/System.err(31396): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1857)
W/System.err(31396): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:824)
W/System.err(31396): at com.a.a.b.getReadableDatabase(Unknown Source)
W/System.err(31396): at com.XXXXX.XXXXX.x.a(Unknown Source)
W/System.err(31396): at com.XXXXX.XXXXX.ay.a(Unknown Source)
W/System.err(31396): at com.XXXXX.XXXXX.ay.doInBackground(Unknown Source)
W/System.err(31396): at android.os.AsyncTask$2.call(AsyncTask.java:185)
W/System.err(31396): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
W/System.err(31396): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
W/System.err(31396): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
W/System.err(31396): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
W/System.err(31396): at java.lang.Thread.run(Thread.java:1019)
场景三:应用程序版本 2.0 在市场上可供用户下载
第 1 步 -用户已经拥有应用程序 1.5 的先前版本(自行卸载应用程序并手动进入市场并安装应用程序。没有错误
我很困惑为什么在场景 2 中抛出异常。升级与安装和卸载相比是否有不同的工作方式,以及为什么它说目标文件夹不可写