2016-07-11 45 views
0

我創建了一個SQLite數據庫與「SQLite專家」,它的名字是「dbtest」。 我把它複製到資產的文件夾,當我運行程序它顯示這個對話框: enter image description here添加外部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添加一個格式)

+0

你的問題是什麼?你要問的是什麼問題? –

+0

如果我在對話框中選擇文本,則會出錯 – ahmadsfff

+0

在Android Studio對話框中?向Google/Jetbrains報告錯誤。 –

回答

0

它不是真的將外部數據庫導入到android programs.we可以在兩個類的項目中創建它。

相關問題