How to copy another database apps to SDCard

I've install an application to my device. But i want to copy that database to SDcard to be used by my apps. I used this code to copy database. But it's failed. And need "su" command

public void copydatabase() throws IOException{
    String [] cmd1 = { "su", "cp", "/data/data/com.apps/databases/data01.db", "/mnt/extSdCard/data01.db"};
    Process process = new ProcessBuilder(cmd1).start();
    try {
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block

Any some code to copy that to SDCard without "su" command??


public static void copyDataBase(Context mActivity) throws IOException {
        InputStream myInput = new FileInputStream(
                new File("/data/data/" + mActivity.getPackageName()
                        + "/databases/" + "xyz.sqlite"));
        File files = new File("/sdcard/files/");
        String outFileName = "/sdcard/files/xyz.sqlite";
        OutputStream myOutput = new FileOutputStream(outFileName);
        byte[] buffer = new byte[1024];
        int bufferLength;
        while ((bufferLength = > 0) {
            myOutput.write(buffer, 0, bufferLength);

I hope its useful to you...

Need Your Help

How to get coordinates of an address in android

android google-maps google-maps-api-3 gps

How do i get gps co-ordinates of the location/address entered by user in android ?