Where is the location of my sqlite database file?
hi everyone,
nowadays i am trying to make an app using sqlite database. from many sources i've read, titanium embeded sqlite on it. My qustions are when i wrote :
var db = Titanium.Database.open('testdb');
db.execute('CREATE TABLE IF NOT EXISTS Student (ID INTEGER PRIMARY KEY, NAME TEXT)');
1 where is the location of my database file (something like .sqlite or .db or something like that) on my mac and windows directory if i deploy the app using simulator (iphone and android)?
2 what is the extension of the file?? (.sqlite or .db or kind like that)
3 where is the location of my database file if i install the app on device? may i move that file to external storage device like sdcard?
thx for answering
regards,
Wilson
1 Answer
-
Accepted Answer
Hi Wijaya,
On android, you can inspect your sql file by opening your workstation OS commandline/shell and entering these commands:
- adb -e shell [this will take you to the emulator's shell. The commands are a bit limited, and sadly there is no commandline completion :( ]
- cd /data/data/com.yourdomain.yourapp/databases/ [this is where your app's databases are created]
- ls [your database file should have a .db extension]
- sqlite3 <yourdatabase.db>
- .help [to see sqlite3 help that will state which commands are available]
So, for example, if you created a "todo" database like this:
var db = Titanium.Database.open('todos'); db.execute('CREATE TABLE IF NOT EXISTS todos \ (id INTEGER PRIMARY KEY, todo TEXT)');
1) your database file would be /data/data/com.yourdomain.yourapp/databases/todo.db
2) the extension would be .db
3) in your application, you could copy it to your removable storage using Titanium.Filesystem