我使用" SQLite Expert"创建了一个SQLite数据库。它的名字是" dbtest"。 我将其复制到assets文件夹,当我运行程序时,它会显示此对话框:
这是将数据库复制到数据文件夹的方法:
public final String path="data/data/sqlitedatabaseexample.example.ahmad.sqlitedatabaseexample/databases";
public final String Name ="dbtest";
public void copydatabase() throws IOException // method for copy database from assets folder to program's data folder
{
OutputStream myoutput = new FileOutputStream(path+Name); //destination address
byte [] buffer = new byte [1024];
int length;
InputStream myinput = mycontext.getAssets().open("dbtest"); // file name that is in Assets folder
while ((length = myinput.read(buffer))>0)
{
myoutput.write(buffer,0,length);
}
myinput.close();
myoutput.flush();
myoutput.close();
}
我该怎么做?(我不想为dbtest添加格式)
答案 0 :(得分:0)
将外部数据库导入android程序是不正确的。我们可以通过两个类在项目中创建它。