Android从附加数据库中选择 [英] Android Select from attached database
本文介绍了Android从附加数据库中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Android应用程序,在其中我已将数据库附加到当前数据库连接中,但是当我尝试从附加数据库中的表中进行选择时,出现错误消息,报告没有该表。
I have an Android application where I have attached a database to my current database connection, but when I try to select from a table from the attached database I get an error reporting that there is no such table.
SQLiteDatabase dbc;
try {
dbc = openOrCreateDatabase(DATABASE_RECOVERY,Context.MODE_PRIVATE,null);
dbc.execSQL(TABLE_COMPLETE);
dbc.execSQL("ATTACH DATABASE '" + DBRECOVERY_FULL_PATH + "' as MasterDb;");
dbc.execSQL("SELECT * FROM MasterDb.properties;");
db.close();
dbc.close();
} catch(SQLException e) {
Toast.makeText(getApplicationContext(), "SQLException: " + e.toString(),
Toast.LENGTH_SHORT).show();
}
我也尝试过:
dbc.execSQL("SELECT 'MasterDb', * FROM MasterDb.properties;");
但是每次报告都没有这样的表。
But each time, it is reporting that there is no such table.
推荐答案
我遇到了同样的问题。我忘了在附加新数据库之前将其复制到文件路径。
I had this same issue. I forgot to copy the new DB to the file path before attaching it.
这篇关于Android从附加数据库中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文