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

我在我的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, 0, 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" />

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能