0
我创建了一个SQLite数据库与“SQLite专家”,它的名字是“dbtest”。 我把它复制到资产的文件夹,当我运行程序它显示这个对话框: 添加外部SQLite数据库到android工作室
这是用于复制数据库的数据文件夹的方法:
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添加一个格式)
你的问题是什么?你要问的是什么问题? –
如果我在对话框中选择文本,则会出错 – ahmadsfff
在Android Studio对话框中?向Google/Jetbrains报告错误。 –