com.j256.ormlite.android.apptools.OrmLiteBaseTabActivity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ormlite-android Show documentation
Show all versions of ormlite-android Show documentation
Lightweight Object Relational Model (ORM) Android classes
package com.j256.ormlite.android.apptools;
import android.app.TabActivity;
import android.content.Context;
import com.j256.ormlite.support.ConnectionSource;
/**
* Base class to use for Tab activities in Android.
*
* For more information, see {@link OrmLiteBaseActivity}.
*
* @author kevingalligan
*/
public abstract class OrmLiteBaseTabActivity extends TabActivity {
private H helper;
/**
* Get a helper for this action.
*/
public synchronized H getHelper() {
if (helper == null) {
helper = getHelperInternal(this);
}
return helper;
}
/**
* Get a connection source for this action.
*/
public ConnectionSource getConnectionSource() {
return getHelper().getConnectionSource();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (helper != null) {
OpenHelperManager.release();
helper = null;
}
}
/**
* @see OrmLiteBaseActivity#getHelperInternal(Context)
*/
protected H getHelperInternal(Context context) {
@SuppressWarnings("unchecked")
H newHelper = (H) OpenHelperManager.getHelper(context);
return newHelper;
}
/**
* @see OrmLiteBaseActivity#releaseHelper(OrmLiteSqliteOpenHelper)
*/
protected void releaseHelper(H helper) {
if (helper != null) {
OpenHelperManager.release();
helper = null;
}
}
}