How to access a SQLite database in an Android application?

advertisements

I cannot for the life of me figure out how to access a SQLite DB over multiple activities in an Android application. I tried using an application class but it will not work. Can someone please show me an example of how this would work? I basically have a tab bar setup and need to access the DB from each tab.

Thanks


Make your DB class a singleton and you will be able to use it from all activities. Do not close the database, it will be closed automatically when the app process ends.