[英]Android SQLite database being deleted on “SQLiteDatabase.openDatabase”
I copy over a valid Android SQLite database from the apk to the databases folder on my AVD. 我将有效的Android SQLite数据库从apk复制到了我的AVD上的databases文件夹中。 I verify with the DDMS FileExplorer that it is there and the size is correct.
我使用DDMS FileExplorer验证了它的存在和大小是否正确。 When I call the following function to open it,
当我调用以下函数打开它时,
mDb = SQLiteDatabase.openDatabase(mDatabase_path, null,
SQLiteDatabase.OPEN_READONLY);
The SQLite DB file is deleted and a SQLiteException, "Unable to open database" is thrown. 删除 SQLite数据库文件,并引发SQLiteException,“无法打开数据库”。
What could be deleting it if it exists before the line, then is gone after? 如果它在行之前存在,然后在行之后消失了,该怎么删除?
Ian 伊恩
My copy function was missing the first byte so corrupting the DB. 我的复制功能缺少第一个字节,因此损坏了数据库。 Android will in that case delete the DB and try to recreate it.
在这种情况下,Android将删除数据库并尝试重新创建它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.