I am using Sugar ORM in my Android application. I have managed to save/read data to/from the database successfully. Now I am in the need to get the created database and check some info for debugging etc. I might also need to use a prepopulated db the first time.
How can this be done in Sugar ORM? I can't find anything in the documentation.
If it cannot be done, Please propose any other easy-to-use ORM that has this ability. (Don't tell me OrmLite, it is not easy to use such as sugar orm)
I see you ask this quite a while ago but I am just finding it.
You can connect adb (Android Debug Bridge) to your device and open an adb shell.
Then in this shell navigate the shell to the database directory and use the SQLite3 command to access the database.
It works quite well in Android studio with the emulator. I have not tried it with other environments yet.
You can't do it using Sugar ORM right now. There is already an issue to pre-populate data using the migration script, see https://github.com/satyan/sugar/issues/87.
Another quite similar ORM to use would be DBFlow which is also very easy to use.(https://github.com/Raizlabs/DBFlow). I just made a POC using a prepackaged database which worked fine. See https://github.com/Raizlabs/DBFlow/blob/master/usage/DBStructure.md for more details how to do that.
Edit: Also check out ActiveAndroid which seems to be very similar to Sugar ORM and also supports pre-populated databases (https://github.com/pardom/ActiveAndroid).
Related
I'm using sugar orm in my android application and its already in Google Play Store.
Now I want to update my database schema and send an updated apk to Google Play store
However there is a problem while I'm trying to update my schema with following the official documentation of sugar orm.
(Adding version sql files with neccesary alter commands like alter table ....)
For figuring out the problem, I'm looking for the actual sqlite database file in the device, but I am not able to find it in anywhere.
I'm using genymotion emulator as samsung galaxy s6 device , so do you think is it something related with that? Or do you think are there any other problem
Does anyone know how can I find the actual sqlite database file path for sugar orm
Thanks
Found the solution here
https://gist.github.com/sibeliusseraphini/b060c415604c52c2a94e
So I could pull the db file and then figure out the problem
"Column names must be upper Case"
I am considering using ORMLite for persistance in an android app. A requirement is to be able to sync the underlying android SQlite database across multiple android devices.
Is this possible with ORMLite? And how?
You can directly copy the database file over to another device and it will work if you didn't change the schema.
I wouldn't recomment that though. Instead you could load the Object tree from your db using ORMLite, copy it over, and write it back to the db with ORMLite. You might want to look into SyncAdapters too.
I'm working on an app that uses sqlite to store data and I need/would like to view the tables in the app to be sure things are being added correctly and the content exists. How do I review the tables and their data being used in my app.
I'm using a Nexus 7 with 4.4 on it for testing the app.
You have basically two choices.
Run the app in the emulator, then "pull" the db to your dev machine and use a tool such as SQLite Expert Personal 3 to view the db.
Create your db in the external storage instead of internal. Then you can use your USB connection to "pull" the db.
I guess I can add (3): add code to dump your tables to the log file.
I don't know this can solve your problem or not but installing THIS plugin into eclipse help me a lot to view database table and content inserted.
Is there a way to connect to the SQLite database while the emulator is running and do manual queries against the database?
The following is a basic sequence of steps I'm looking to achieve:
Query user table.
Add a user via the program.
Query user table to verify add successful.
Yes there is, and there's even a guide on the Android developer site.
From an adb remote shell, you can use the sqlite3 command-line program
to manage SQLite databases created by Android applications.
Note that you can also copy the database file out of the emulator using DDMS, and then examine it with tools like SQLiteStudio.
This is an old question but if anyone still looking for this then Facebook Stetho is the best tool for debugging DB related stuff:
http://facebook.github.io/stetho/
Only downside is that you need to add a couple of line to your gradle script and application class. But well worth it.
I want to debug database on android device. My application is very heavy and I do too much insertion queries and other stuff so running on emulator is hell slow so I am debugging it on Android phone.
But I could not debug database, like in Iphone you can see even insertion made into database. I want to see the current situation of database without rooting my phone and pulling it from my phone and then opening it into some 3rd party software.
Is there any way to debug Android database on mobile phones without rooting and pulling database out?
There is tool sqlite3 but the problem is that when you connect to shell it shows you ugly data and furthermore if database is not created running any query actually creates database in database folder so you would never knew that your database was not created by your logic.
I hope you understand what I am looking for.
I had the very same problem and after a search I found this one SQLiteManager plugin for Eclipse which is a plugin for eclipse allowing you to see and browse your data strait from SQLite DB
To use this it's easy, start you emulator, browse the emulator files in the DDMS view then
go to data > data > com.your.package > databases > your_database_name.db (note the db extension is mandatory)
and a new tab will appear with your data!
It won't work on a real device (maybe on a rooted one?)
Hope it will work for you :)
There is information on how to connect eclipse to a sqlite database here. Another alternative is using this Firefox add-on to manage your sqlite database.
I'm still looking into it myself but there is MOTODEV Studio for Android, requires free registration.
See the next simple, single JAR file.
on google code