I have made my database using greendao and Have been testing it on the emulator so far. It was working so perfectly. And there was no memory leak and any error whatsoever .
But now I am stuck to just one single point. and that is how do I use this
pre-populated database in the application on the real device. How can I push my database into real device?
Some one suggest me to put my database file in the assets folder and later on Application start just copy it into device.
The suggestion was good, but it is not helping me as there comes the error when I run my application for the first time , but after that it goes forward But then greendao is unable to get the database it find.
The error I got at first run is as under.
can not open database
Buton second run it goes forward and there in next activity I am getting data in list using greendao , but it is not finding that database.
Please tell me :
1) How can I push my pre papulated database into the device to be use by greendao methods.
2) What is a way that is supported in all devices.
Please share me the code. Its been a long I am trying to get over this. But nothing is helping me out.
I made a simple dictionary demo for Android, which manipulates prebuilt database in assets folder with GreenDAO 3.x.
All you have to do is extended the DevOpenHelper class that GreenDAO generates.
Here is the project link: Sawloih.
Related
I have a 15mb database .
I need to encrypt it , so it can't be readable easily .
I'm using SQLCipher , it works fine for a new database but I've made my database and I need to encode it now . How can I do so ?
My database is in asset folder or will be downloaded when user runs the app for the first time, I don't want my app to get data from internet because it should be an offline application.
How can I encrypt my database with all it's data?
You will want to use the sqlcipher_export(…) function, specifically example 1 found in the documentation here. You can also find an example of this within the SQLCipher for Android test suite here.
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.
First I want to say thanks to everyone that reads this. Stackoverflow is an amazing site and you guys help me out with answers everyday in the form of questions already submitted. You all rock!
My problem:
I'm working on a database app that I'd like to back up the database at certian points so I can save the data I've collected in database over time, during development. So to save the database to accessible memory I've followed this page:
How can I pull databases off my android onto my desktop?
..and the above code is working great in the emulator (I can use DDMS to pull the copy of the database to my PC and view it using SQLite Database Browser). However when I run it on an actual device, SQLite Database Browser can't read it. To extrapolate, the copy is being created just fine on the SD card, but when I copy to my PC from my device and view it, I get nothing, SDB can't understand it or something. However when I use an emulator, I can copy it off using DDMS and view all the tables just fine with SDB.
Using WinMerge to compare the two raw database files (one generated by the device, one generated by the emulator both running the same code) I can see there are formatting differences, but nothing that looks corrupted, but I'm not 100% sure. The android metadata and SQL sequence tables appear to be in there (albeit in different orders), as well as my custom table.
Do you guys have any suggestions on how to debug this? I'm not sure where to start since it seems to work perfectly on the emulator. Also, I've run the emulator at the same android release (2.3.3) as the device, so I'm am pretty sure they are using the same SQLite engine.
Thanks,
Matt
I'd try opening this database with different SQLite clients.
If that doesn't work, the next step may be to try finding an SQLite database file validator and/or to run the standard SQLite client in debug mode (but to be honest, I don't even know if those two last options are even possible).
Hello
I'm working on an android program that uses a database. My database is going include about 300 to 400 records.
My question is what is be best way to work with the database.
Should I create the database at run time via code and insert the records "manually" every time the program starts, or should I use an external database, that's located in the /assetes folder of the program?
If the second option is the way to go, could someone please give me an advice on how to do that, because I can't find any toturial that covers this subject.
Thank you!
There's another option, which is to initialize the database the first time the program is launched. See the SQLiteOpenHelper class, and especially the onCreate method in that class.
Here is a tutorial for the 2nd option you mentioned.
Put your db in the asset folder and if DB does not exist in /data/data/YOUR_PACKAGE/databases/, it will copy the database over.
I am trying to connect my android application to sqlite, i dont knw how to configure SD card in emulator to have a database... can anyone help me please?
You don't need to configure an SD card in the emulator to create and use a sqlite database. You can create an SQLiteOpenHelper class that will do all the work of creating, opening, upgrading and other tasks on the database.
You can follow the tutorial on this link to understand the entire process. The blog has really explained the entire thing in a very simple manner and plus, also gives you the entire tutorial project as a download too.
Android Sqlite Database tutorial