Tuesday, January 29, 2013

Packaging Existing SQLite Databases With Your Google Android Application

Many examples of Android applications on the Internet assume that the apps you develop will, by default, create a new, blank MySQL database at its first run-time.  However, there aren't many examples of a situation where one would create a separate MySQL database which would then be used by the Android application.  A potential solution, borrowed from databases on other platforms that use Continuous Integration, would be to embed seeding SQL statements in the application to run on creates or upgrades, but this may be prohibitive for some developers in terms of practicality and time, in addition to the fact that Android does some backend wizardry with SQLite databases to have them work properly with its SQLiteOpener class.  So, how would one embed an existing SQLite database to the application's assets folder and use it at runtime?  Stay tuned for the solution after the jump!