Browsing Android SQLite database within application - android

Does anyone know of Android code I could embed directly in my app, such that I could browse my SQLite database directly from within my app?
If not, how about code that reads the SQLite metadata, and dumps table and column names and data to the log? (In JDBC, I'd use databasemetadata to get table info, and then table metadata to get column info...)
I know I can browse on an emulator, and I can copy the db off the device and then point a db browser at it. But this would be a lot more convenient for me during development. This would of course be used only for test databases with tiny amounts of data. Any suggestions?

Have a look at this question: browse data in Android SQLite Database It may not be exactly what you're asking, but may be sufficient for your needs.
Alternatively, there's a sqlite database browser app in the market, which you may be interested in (I haven't tested it myself): https://market.android.com/details?id=com.xuecs.sqlitemanager&hl=en

I think this is what you are looking for .
Using the library in the link below you can browse your app database from your app https://github.com/sanathp/DatabaseManager_For_Android
With this library you can manage your app SQLite database from you app itself.
you can view the tables in your app database , update ,delete, insert rows to your tables .Everything from your app.
Its a single java activity file ,just add the java file to your source folder.When the development is done remove the java file from your src folder thats it .
It helped me a lot .Hope it helps you too .
You can view the 1 minute demo here : http://youtu.be/P5vpaGoBlBY

Related

How to insert a database into an Android application

I have created a database which contains 4 tables using Firefox plugin. The format of the saved database is .sqlite(name.sqlite).
I just want to know how/where to insert it into the android project that I am developing and what the changes are that I should make in my project (like changes in the Manifest file). I guess I should paste it into an asset folder, but I do not know how to access it in the code.
I want to add, view, update and delete data in the table, how should Ido this? Or Should I use another way?
This is a pretty solid tutorial: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/
Basically, don't copy your sqlite file directly into the project. Follow the steps and create / upgrade your database in the provided onCreate and onUpgrade hooks.
These hooks give you the opportunity to change your database structure when publishing updates through the Play Store.
And the proper places to do longer running operations to upgrade all your data, or prefill your data from disk/network.
If you want to prefill your DB from a dataset, you can provide that data in a raw XML, or JSON, or CSV, and after your onCreate do all the inserts when the app launches from a fresh install.
Here is some good tuts for sqlite...
http://coderzheaven.com/2011/04/using-sqlite-in-android-a-really-simple-example/
http://androidexample.com/SQLite_Database_Manipulation_Class_-_Android_Example/index.php?view=article_discription&aid=51
http://www.vogella.de/articles/AndroidSQLite/article.html

Dragging and Dropping a SQLite database between projects

I see a sqllite database in another application, why can't I just just drag and drop from that application to mine in the eclipse environment? that way I can use data already in that database?
Android doesn't do too well with using an sqlite database file directly. Generally the way to go around it is to package an sqlite database as a resource and on first create of the app to load that resource and then connect to it and then copy all the data out of it. The downside of this is you are essentially doubling all your data.
If you are the publisher of the other app then you can list the database as a shared database to share between your apps.
Share SQLite database between 2 android apps?
Noone has written an Eclipse plugin that does that. You can write one if you feel it is both useful and worth your time.

Android App: can I use iOS sqlite? If not, how do I create a local database from a database in the cloud (Parse.com)?

I am making an Android version of an iOS app that I already have. I want to use a local database so that the user can use most the app offline.
Initally I thought I could use the sqlite database created by Core Data in Xcode, but as I am reading things online it seems like this is not possible. Is this true? Or is there a good way to export it to something Android could use?
If not, I want to create a local database with values from a database on the cloud(I use Parse.com). How can I do this? The data on the cloud doesn't change very often (maybe twice or thrice a year) if that makes any difference.
This is a good tutorial to handle preloaded databases:
http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
Essentially, once you have your precreated database, put it in your assets directory in your apk. Then on first app use, copy this from assets to "/data/data/YOUR_PACKAGE/databases/" directory.
You have to create the database by code in Android, using a DatabaseHelper http://developer.android.com/guide/topics/data/data-storage.html#db. If you want to use your already created database you will have to export it to SQL statements and then "import" them to your application.

How do I view my sqlite tables in my android app?

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.

How to store a large number of words (to be accessed by an android app)?

I have a list of words (112,000 in alphabetical order) with one word definitions. The definitions are sometimes more than one and are in the format:
word:definition1|definition2|...
The max number of definitions for a word is 8.
I need a method to store these in a file (or more is okay) so they can be accessed by an android app. Only one word will be accessed at a time. This list will never change.
Considering SQLite, how would I insert the large data into a database?
Considering RandomAccessFile, how would I create a index for these words?
Is there another way?
Thanks.
I would suggest you to go with SQLite as it would be easy to fetch data as and when required and it would be simply easy to get/date/update data from particular position too.
One more benefit is that you can prepare SQLite database by using GUI tool too.
Now follow below procedure to use Existing SQLite database, means that you will have database ready with words data:
Prepare SQLite database same as we do in .NET , here you can prepare it using one of the best tool SQLite Manager which you can download it as a tool/add-on inside Mozilla Firefox.
Once you are done with database, simple paste it inside assets folder.
Now write a code to copy database from assets folder into our app. There are plenty of examples available on web for the same.
Use a sqlite DB , storing 112,000 or more shouldn't be a problem at all for sqlite .
Your can use your db schema something like the following :
And there can be multiple entries of wordId -> meaningId , for each word .
for pre-storing data you could use a tutorial provided by me in my blog : Using Pre-populated sqlite database in android

Categories

Resources