0

I run all examples of storage class of Phone gap and developed the code as mentioned in

http://docs.phonegap.com/en/2.7.0/cordova_storage_storage.md.html#Storage.

Then at which location the DB file will be created?

user2428352
  • 27
  • 1
  • 3

4 Answers4

1

The location of the database file is different in android 4.4. My app on android 4.1 has the db at "file:///data/data/{package_name}/app_database/file__0/0000000000000001.db" but on Android 4.4 the db file's at "file:///data/data/{package_name}/app_webview/databases/file__0/1".

I wrote a simple plugin for cordova that makes this distinction and returns a string with the full path of the db file. However it's not developed for other platforms like iOS or Windows Phone. Feel free to collaborate.

Bruno_Ferreira
  • 1,305
  • 21
  • 33
  • hi bruno..I am trying the same on Android 4.4 but I am facing the same issue as mentioned over here http://stackoverflow.com/questions/21991630/android-version-4-4-sqlite-error-in-phonegap – Parth Doshi Aug 15 '14 at 17:27
  • I didn't use a prepoulated database as pointed out in the link you referenced, but as you can see in my response, the default database location changes on android 4.4. I think that if you want to use a prepopulated database on android 4.4 you have to copy your database file to "file:///data/data/{package_name}/app_webview/databases/file__0/" and name it just "1". – Bruno_Ferreira Aug 16 '14 at 14:21
  • I tried loading a prepopulated database ..but it seems that the folder structure keeps on changing..see this http://stackoverflow.com/questions/21991630/android-version-4-4-sqlite-error-in-phonegap#comment39485176_21991630 .......do you know any solution for this? – Parth Doshi Aug 16 '14 at 17:36
0

on which platform?

on Android the DB file is located in /data/data/{app.package}/databases and /data/data/{app.package}/app_database (credits: https://groups.google.com/forum/?fromgroups#!topic/phonegap/_OMN5C5flq8)

drS
  • 1
  • 1
  • I am not able to find path of data.Please also answer of this too – user2428352 May 29 '13 at 12:22
  • again: on what platform? If you are using android and Eclipse, open DDMS perspective (Window --> Open perspective --> DDMS) while the emulator is running, click on "file explorer" and navigate to the path I wrote to my answer. – drS May 30 '13 at 12:50
0

If you are using PhoneGap for Android you will find the database you created in the following folder

/data/data/{{full_package_name}}/app_database

Your app database is typically created under a folder like this:

file__0/0000000000000001.db (Please note that the number could change in your specific case, but you get the idea)

If you want to browse the data on that database, you could do

sqlite3 {{db_file_name.db}}
.header on
.tables
select * from {{tablename}}
.schema {{tablename}}
UnTechie
  • 365
  • 2
  • 7
0

The DB file will be stored at /data/data/{package_name}/databases.

I recommend use "SQLitePlugin":

Cordova-SQLitePlugin

Balaji SS
  • 136
  • 1
  • 10