1

I have created a database for my application. Now I want to make sure that all the attributes are correct and rows are getting filled properly. Database seems to be in /data folder but this folder seems to be empty. When I try to use sqlite3 to access it (from the command line using adb shell ) I get a not found error. The android phone that I am playing around is a Google Nexus S. Any ideas on how to export it or test that the database is build correctly and used as intended?

3 Answers 3

5

In the DDMS perspective use the file explorer while an emulator is running. You can explore the folders there. You will find your database in /data/data/your-package-name/databases You can find details about DDMS here

Sign up to request clarification or add additional context in comments.

2 Comments

Please look at the following link, step by step procedure with images, same as @C.d wrote. weston-fl.com/blog/?p=2812
This will only work if your device is rooted - emulators are rooted by default. In many of the devices you will not have access to /data/data to do what you are suggesting.
4

You might find this question helpful:

How do I backup a database file to the SD card on Android?

@skeniver says:

try {
    File sd = Environment.getExternalStorageDirectory();
    File data = Environment.getDataDirectory();

    if (sd.canWrite()) {
        String currentDBPath = "//data//{package name}//databases//{database name}";
        String backupDBPath = "{database name}";
        File currentDB = new File(data, currentDBPath);
        File backupDB = new File(sd, backupDBPath);

        if (currentDB.exists()) {
            FileChannel src = new FileInputStream(currentDB).getChannel();
            FileChannel dst = new FileOutputStream(backupDB).getChannel();
            dst.transferFrom(src, 0, src.size());
            src.close();
            dst.close();
        }
    }
} catch (Exception e) {
}

with @Jakobud adding that you need to have the

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

in your manifest.

Comments

1

You will need to either root your phone, or else use the emulator. On normal non-rooted phones, you don't have permission to access private app data like this.

Read this to see how to export your file for analysis.

5 Comments

At some point either way I will have to get the tables of the database as I will have to perform a data analysis on them. There should be a way of getting those data. As for now, how can I access those data from emulator?
See C.d.'s answer for details on how to browse the emulator's filesystem from Eclipse/DDMS.
Thanks! How about when I will have to export it for data analysis? I will need to export many databases then.
Added link to my answer telling you how to export the data.
Your link just point to your whole web site. Please consider pointing to the article instead of the whole web site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.