
如果您的移动应用程序.这是我将数据库复制到sdcard根文件夹的方法.
/** The name of the database file */ static final String DATABASE_name = "mydatabase.db"; static final String DATABASE_name_FulL = "/data/data/com.my.application/databases/" + DATABASE_name; public static boolean backUpDataBase(Context context){ boolean result = true; // Source path in the application database folder String appDbPath = DATABASE_name_FulL; // Destination Path to the sdcard app folder String sdFolder = Environment.getExternalStorageDirectory().getabsolutePath() + "/" + DATABASE_name; inputStream myinput = null; OutputStream myOutput = null; try { //Open your local db as the input stream myinput = new fileinputStream(appDbPath); //Open the empty db as the output stream myOutput = new fileOutputStream(sdFolder); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myinput.read(buffer))>0){ myOutput.write(buffer,length); } } catch (IOException e) { result = false; e.printstacktrace(); } finally { try { //Close the streams if(myOutput!=null){ myOutput.flush(); myOutput.close(); } if(myinput!=null){ myinput.close(); } } catch (IOException e) { } } return result;} 你需要在manifest.xml中使用它
<uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" />总结
以上是内存溢出为你收集整理的如何下载Android应用程序的sqlite数据库?全部内容,希望文章能够帮你解决如何下载Android应用程序的sqlite数据库?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)