创建从SD卡prestored数据库文件数据库 [英] Create database from prestored db file on SDcard
本文介绍了创建从SD卡prestored数据库文件数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要导入的数据库是超过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);
这篇关于创建从SD卡prestored数据库文件数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文