Skip to content

Instantly share code, notes, and snippets.

@mikeholler
Created March 17, 2014 15:20
Show Gist options
  • Save mikeholler/9601206 to your computer and use it in GitHub Desktop.
Save mikeholler/9601206 to your computer and use it in GitHub Desktop.
Maintain only one static database connection in Android. From http://touchlabblog.tumblr.com/post/24474750219/single-sqlite-connection
public class DatabaseHelper extends OrmLiteSqliteOpenHelper
{
private static DatabaseHelper instance;
public static synchronized DatabaseHelper getHelper(Context context)
{
if (instance == null)
instance = new DatabaseHelper(context);
return instance;
}
//Other stuff... 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment