2

可能重复:
Android sqlite 返回:错误代码 = 14

我已经使用 SQLiteAssetHelper 类/库从 assets/databases 文件夹中操作数据库,如该链接中所示。我完全按照所有说明进行操作,但我仍然无法访问数据库。

09-27 19:35:46.417: I/Database(27474): sqlite returned: error code = 14, msg = cannot open file at source line 25467
09-27 19:35:46.417: E/Database(27474): sqlite3_open_v2("/data/data/com.gatec.douaa/databases/data", &handle, 2, NULL) failed
09-27 19:35:46.428: W/SQLiteAssetHelper(27474): could not open database data - unable to open database file
09-27 19:35:46.428: W/SQLiteAssetHelper(27474): copying database from assets...
09-27 19:35:46.447: W/SQLiteAssetHelper(27474): extracting file: 'database.db'...
09-27 19:35:46.477: E/SQLiteAssetHelper(27474): Couldn't open data for writing (will try read-only):
09-27 19:35:46.477: E/SQLiteAssetHelper(27474): com.readystatesoftware.sqliteasset.SQLiteAssetException: Missing databases/data.zip file in assets or target folder not writable

代码:

public class MyDatabase extends SQLiteAssetHelper {

    private static final String DATABASE_NAME = "data";
    private static final int DATABASE_VERSION = 1;

    public MyDatabase(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);


    }

请问有什么帮助吗?不知道问题的根源。

4

1 回答 1

0

为什么将 .db 文件放在 .zip 中?请尝试将其放入未归档的资产中。或者,您可以尝试在 zip 存档中放入一个没有问题的 .db 文件,以了解问题出在哪里。

于 2012-09-27T20:39:27.173 回答