Search code examples
androideclipseadbdatabasegenymotion

Genymotion. How to pull database from device. my /data/data/ folder appears to be empty


I have an issue with my Ubuntu installation of genymotion. Mainly I am unable to debug my database since both through DBMS in eclipse and adb in shell I can not view content of /data/ folder. There are no files shown.

I log through adb by cd to /sdk/platform-tools and typing ./adb shell su . I see that tab is not working, so I blindly type the path. Anyways I am not able to pull db, maybe I'm doing something wrong with commands.

Through DBMS i try to connect but data folder does not display content.

On Emulator everything works smoothly, but emulator is slow and I would rather use genymotion.

Any suggestions how to deal with this problem?


Solution

  • I managed to kind off go around the issue so I post my solution in case someone will find it helpful.

    Previously I've been creating VM's with no google apis, superUser app crashed every time I wanted to root the phone.

    so I created VM that is provided with google play and downloaded SQL Debugger App. I also use this code in my test suite and so I fetch db to SD-card at the end of every test I run. That way I don't need to have superuser permissions.

    public static void copyDbToSd(Context context) {
        File dbFile = context.getDatabasePath((String) DatabaseHandler.DATABASE_NAME);
    
    
        InputStream myInput;
        try {
            myInput = new FileInputStream(dbFile);
            OutputStream myOutput = new FileOutputStream(
                    Environment.getExternalStorageDirectory() 
                    + java.io.File.separator 
                    + "database.db");
    
            byte[] buffer = new byte[1024];
            int length;
            while ((length = myInput.read(buffer)) > 0) {
                myOutput.write(buffer, 0, length);
            }
    
            myOutput.flush();
            myOutput.close();
            myInput.close();
        } catch (FileNotFoundException e) {
            Log.e(TAG, "Exception: ", e);
        } catch (IOException e) {
            Log.e(TAG, "Exception: ", e);
        }
    
    }
    

    where DatabaseHandler.DATABASE_NAME is name of my database I set at creating db.