Archived

This was once developing into a really nice library, but I no longer write Android code, and this is years old and has bugs. I will not be maintaining or updating it.

databasemanager

Update! There is an updated version available at https://github.com/JakarCo/databasemanager/tree/JakarCo-untested-1 but as the branch name suggests I have not tested it. I need someone else to test it and let me know if it works right and I'll commit to the master branch. You can email me at support@jakar.co

For current information and future updates, see http://forum.jakar.co/databasemanager/210233/ which I will add info to as I have time.

A simple SQLite Database manager that handles threading/synchronization issues

If you're just using this class as it currently is, just copy/paste the source into a new java file in your Andriod project, then extend DatabaseManager (instead of SQLiteOpenHelper) for each database you want on-disk

A very similar implentation of this is included in my Android SQLite Library found at http://androidsqlitelibrary.com/

I personally don't recommend using Android's SQLiteDatabase and SQLiteOpenHelper classes directly. There are quite a few other options, such as greenDao, sugarOrm, OrmLite for Android, JQL (mine), and more. I'm working on compiling a list of options with some basic about pages and how-to guides on my forum at http://forum.jakar.co/android-sqlite/1396714536/ (which will soon be moved to the above site) so that you can compare and choose which is best for you.

Basic usage:

MyDatabaseManager dbManager = new MyDatabaseManager(context);//this opens the database
SQLiteDatabase db = dbManager.getDb();
//Later, I will make DatabaseManager interface with SQLiteDatabase directly, just so nobody uses it wrong.
db.someFunction();//use the SQLiteDatabase instance as you normally would.
//close the database when you're completely done.
//for activities, opening (instantiating) in onStart and closing in onStop is a good practice because it prevents from leaking connections.
//if you need it in onCreate, then open it there and conditionally open in onStart, then always call close in onStop and conditionally in onDestroy (if onStop was skipped).