简体   繁体   中英

Android How can I see my SQLite?

I used Eclipse to open data/data/your.package.name/databases ,but there's nothing in data .

Some people say I didn't get the "root privileges".

How can I see my SQLite?

The easiest way, I think, to write a small function in your app, which copies the /data/.../etc to the /sdcard/ , or somewhere else.

After that, you'll be able, to open that DB from your computer.

Here's a full answer, how to copy the file into the SDCard: https://stackoverflow.com/a/19093736/2891426

I would implement this function in a whole new class, and create a button, which calls this. Or something like this.

And you can download a small Windows app from here, to browse the DB file: http://sqlitebrowser.org/

You do need root access to see the databases on your device. You can use an emulator though, instead of the physical device, and that will allow you to explore the databases in Eclipse.

you don't need to have root privileges to access external storage. you need for internal storage though. in eclipse in ddms go to android/data/yourpackage and there you should find all files created by your app. if there is no file, then there is no database. once you find your database you can use sqliteman to see its content http://sourceforge.net/projects/sqliteman/files

best solution would be to use internal storage and then just export it to external when you want to access it. look here: https://stackoverflow.com/a/19093736/2026478

public void exportDatabse(String databaseName) {
    try {
        File sd = Environment.getExternalStorageDirectory();
        File data = Environment.getDataDirectory();

        if (sd.canWrite()) {
            String currentDBPath = "//data//"+getPackageName()+"//databases//"+databaseName+"";
            String backupDBPath = "backupname.db";
            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) {

    }
}

You Should Use SQLiteBrowser For That You can Easily Access Your Database. You Can Download from here http://sqlitebrowser.org/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM