如何下载Android应用程序的sqlite数据库?

如何下载Android应用程序的sqlite数据库?,第1张

概述我在我的 Android应用程序中使用sqlite数据库.我想将数据库下载到pc.任何人都可以告诉我该怎么做? 如果您的应用程序在模拟器中,您只需使用DDMS并打开/data/data/your.package.name/databases. 如果您的移动应用程序.这是我将数据库复制到sdcard根文件夹的方法. /** The name of the database file */ s 我在我的 Android应用程序中使用sqlite数据库.我想将数据库下载到pc.任何人都可以告诉我该怎么做?解决方法 如果您的应用程序在模拟器中,您只需使用DDMS并打开/data/data/your.package.name/databases.

如果您的移动应用程序.这是我将数据库复制到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数据库?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1121858.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存