ausgeorge
ausgeorge

Reputation: 1015

manually edit SQLite DB on AVD?

Is it possible to edit the data in a virtual device's sqlite db? Or, can I export it, manipulate it, upload it?

It's the db for my own app, nothing nefarious! I just want to test things with certain data. thanks NB: I know the location of the data.

Upvotes: 0

Views: 914

Answers (3)

Jerome
Jerome

Reputation: 1281

You can use SQLiteDatabaseBrowserPortable

To get the database from your device without being root, just do

adb exec-out run-as <app-package-name> cat /data/user/0/<app-package-name>/databases/<database-name>.db > c:\tmp\test.db

Upvotes: 0

N.K
N.K

Reputation: 1690

Yes, it is, i personnaly use some sort of plugin you need to build your app with and then i go to chrome://inspect, i'll have my DB in the device list once my app is running (emulator or not, if it's a real phone, works as long as it's connected via usb for debugging).

The plugin name is Stetho.

You need to put this in your build.gradle

dependencies {
    compile 'com.facebook.stetho:stetho:1.3.1'       
    compile 'com.facebook.stetho:stetho-okhttp:1.3.1'       
}

And launch it this way in your code:

Stetho.initialize(Stetho.newInitializerBuilder(this)
        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
        .build());

After this like i said, emulator or not just launch your app and go to chrome://inspect then click on your device to open up the explorator, select sqlite DB or wichever DB type you use and navigate to your DB, then click on it. You will then have access to all the tables etc and a console (similar to phpmyadmin's organization for example).

Really simple, i love Stetho.

Upvotes: 1

Manish Gupta
Manish Gupta

Reputation: 139

Yes you can see or edit data in SQLite db from your device. just add this This is probably the finest and most useful code I have used. Need any help in this. I will be happy to help you

Upvotes: 0

Related Questions