2

I have been looking for hours now how to see my database using the program DB Browser for SQLite (http://sqlitebrowser.org/).

I downloaded the software and i can't find any file on my computer that can be opened with this software.

So what kind of file android SQLiteOpenHelper class generates? And how can i open it using the software mentioned(Or any other way i can see my database?).

I'm not using emulator. I run my app on an actual device.

EDIT So i guess i need to do this adb pull data/data/package-name/databases/database-name and i really dont know how to do it.

God
  • 1,238
  • 2
  • 18
  • 45
  • Why not using [SQLite Debugger](https://play.google.com/store/apps/details?id=oliver.ehrenmueller.dbadmin&hl=en) – Tony Nov 28 '15 at 09:01
  • @Tony Never heard of it. Just installed it.I will check it out. – God Nov 28 '15 at 09:02
  • 1
    Alright, make sure you root your device – Tony Nov 28 '15 at 09:03
  • @Tony My device is not rooted so i cant open it with SQLite Debugger.It says i can only open it using sd card. – God Nov 28 '15 at 09:03
  • 1
    Try root your device and see – Tony Nov 28 '15 at 09:04
  • Possible duplicate of [How to view the sqlite database in device android](http://stackoverflow.com/questions/19194576/how-to-view-the-sqlite-database-in-device-android) – Iamat8 Nov 28 '15 at 09:04
  • http://stackoverflow.com/a/33722841/1841194 – frogatto Nov 28 '15 at 09:06
  • @Mohit I have already checked that post(Even voted) but foound no solution for my problem. – God Nov 28 '15 at 09:06
  • @Tony If i dont want to hack my device? :) – God Nov 28 '15 at 09:06
  • @God I would suggest you to root your device. The app I suggested to you quiet easy to use – Tony Nov 28 '15 at 09:09
  • @Mohit So in that thread he says to run this command `adb -d shell "run-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/"`. I dont know how to run it. – God Nov 28 '15 at 09:11
  • write the command in your (windows) cmd / (Linux) Terminal – Iamat8 Nov 28 '15 at 09:15
  • @Mohit In cmd its not recognizes the `adb` command. – God Nov 28 '15 at 09:18
  • you have to set path for that..check [this](http://android.stackexchange.com/questions/38321/what-do-i-type-in-path-variable-for-adb-server-to-start-from-cmd) and [this](http://jaxov.com/2010/10/set-up-adb-on-windows-7-vista-xp-for-android-phones/) – Iamat8 Nov 28 '15 at 09:22
  • @Mohit I cant manage to set the path. I tried `C:\Users\volca_000\AppData\Local\Android\android-sdk`. Is that the path i need to enter? – God Nov 28 '15 at 09:42
  • In my case (I'm using Eclipse, on Windows), it's `C:\Program Files\Adt-Bundle\sdk\platform-tools` – Phantômaxx Nov 28 '15 at 09:50
  • @Mohit No. When i run the `adb -d shell "run-as com.yourpackge.name ls /data/data/com.yourpackge.name/databases/"` command i get `/data/data/com.example.mylifeinformationsharedsocial/database/: No such file or directory` – God Nov 30 '15 at 15:41

1 Answers1

1

In my development i encountered same issue. Your database gets saved in "/data/data/yourapp/database.db".

This is not reachable by default. You have to root your device to view this location. This is something i didn't do. Instead i saved my database in another location that is reachable by default.

public static final String database_path = Environment.getExternalStorageDirectory() + "folder name";

Then i went in the Android Device Monitor and looked at that location to find my database.

Once i found it i used SQLiteStudio to view my database and look if everything is in order.

See http://sqlitestudio.pl for more information

Does that help you out ?

Update 1

You can put your database where you like, any folder you haver permission on. Then you will have to add the path to your constructor of your helper.

public MyDatabaseHelper(Context context) {
    super(context, DATABASE_PATH + DATABASE_NAME, null, 8);
    this.myContext= context;
}

How do you get your database? You copy it or you create it programmatically?

SamuelD
  • 333
  • 2
  • 10
  • Where did you exactly wrote that path line of code? – God Dec 01 '15 at 18:33
  • In your helper class for your database. My predefined db is in the assets folder, where i copy it locally into the device at the location i want. Be sure to set in the manifest, write external storage...See http://developer.android.com/training/basics/data-storage/databases.html for reference – SamuelD Dec 01 '15 at 18:41
  • Thanks. i will look after that tomorrow. – God Dec 01 '15 at 20:06
  • The `"folder name" is any folder i choose? Like to open a new folder an call it db and store it there? – God Dec 03 '15 at 20:35
  • I do it programmatically. i Created a folder called`UsersDb` and then i wrote in the `SQLiteOpenHelper` class `public static final String DATABASE_PATH = Environment.getExternalStorageDirectory() + "UsersDb";` and now i only need to add the path to the constructor like you wrote? – God Dec 04 '15 at 08:18
  • You should rerun your project. Set your DB version higher so the onupdate db get executed. Or just delete and reïnstall your app. Can you see your db now ? Between your path and dbname , i would put a package name like "be.name.com". – SamuelD Dec 04 '15 at 08:24
  • Man i'm, sorry but i really dont understand. I think ill pass for now. Thanks for the help though. – God Dec 04 '15 at 08:37