外部 SQLite 文件内容访问错误
我有以下代码,它给出了如下运行时错误。为什么?
try{
String myPath = DB_PATH + DB_NAME;
mDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){}
运行时错误:
:sqlite returned: error code = 1, msg = no such table: android_metadata
:SELECT locale FROM android_metadata failed
:Failed to setLocale() when constructing, closing the database
:android.database.sqlite.SQLiteException: no such table: android_metadata
I've the following code, it gives a run time error as below. Why?
try{
String myPath = DB_PATH + DB_NAME;
mDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
}catch(SQLiteException e){}
Runtime Error:
:sqlite returned: error code = 1, msg = no such table: android_metadata
:SELECT locale FROM android_metadata failed
:Failed to setLocale() when constructing, closing the database
:android.database.sqlite.SQLiteException: no such table: android_metadata
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保表名
android_metadata
存在,并具有列名locale
,您可以插入 en_US 作为locale
的值。或者执行此 sql 语句:
编辑:如果您使用 SQLiteDatabase.NO_LOCALIZED_COLLATORS 标志调用 openDatabase(),则不需要此表,否则您将需要此表。
请参阅 setLocale()。
Make sure the table name
android_metadata
is there, with a column namelocale
, you could insert en_US as value forlocale
.Or rather execute this sql statement:
Edit: If you call openDatabase() with SQLiteDatabase.NO_LOCALIZED_COLLATORS flag, you would not need to have this table, else you will need to have this table around.
See setLocale().
当打开只读数据库且尚未创建该数据库时,请使用 NO_LOCALIZED_COLLATORS。
如果您以写权限打开数据库,则会创建 android_metadata 表。
When open read only db and its not already created, use NO_LOCALIZED_COLLATORS.
android_metadata table will be created if you open the database with write permissions.
使用 SQLiteDatabase.NO_LOCALIZED_COLLATORS 标志调用 openDatabase() ,这是我上次遇到问题时所做的...
call openDatabase() with SQLiteDatabase.NO_LOCALIZED_COLLATORS flag,this is what i did when i met the problem last time...