创建从SD卡prestored数据库文件数据库数据库文件、数据库、SD、prestored

2023-09-07 10:49:39 作者:空洞的目光ぇ

我要导入的数据库是超过5MB的。当我把.db的资产文件夹中我得到了一些错误。所以我拆分数据库分成更小的DB文件和组装件,以创建数据库。那么,有什么办法可以从SD卡导入数据库,并开始使用DB没有分裂和组装?

The database i want to import is over 5Mb. When i put the .db in asset folder i got some errors. So i split the database into smaller db files and assemble the pieces to create the database. So is there any way i can import the database from sdcard and start using the db without splitting and assembling?

先谢谢了。

推荐答案

是的,有:放在SD卡里面的数据库文件,然后创建一个类中的方法,该方法是这样的:

Yes, there is: place the database file inside the sdcard then create a method inside a class, the method is like:

public class DB_Path {
    public final SQLiteDatabase getOrders() {
            File dbfile = new File("/sdcard/TheDataBaseFile");
            SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
                 return db;
        }
}
-----------------------

初​​始化像

public DB_Path dbp = new DB_Path();
    public SQLiteDatabase db = dbp.getOrders();

之后,你可以调用光标分贝。

after that you can call the cursor with db.

  Cursor cur = db.rawQuery("the sql query",null);