本文整理汇总了Java中com.j256.ormlite.android.apptools.OpenHelperManager类的典型用法代码示例。如果您正苦于以下问题:Java OpenHelperManager类的具体用法?Java OpenHelperManager怎么用?Java OpenHelperManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenHelperManager类属于com.j256.ormlite.android.apptools包,在下文中一共展示了OpenHelperManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initGlobalObjects
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
private static void initGlobalObjects(Context context, Options options) {
GlobalObjectRegistry.addObject(OpenHelperManager.getHelper(context, DatabaseHelper.class));
Gson gson = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
.create();
GlobalObjectRegistry.addObject(gson);
ImageLoader.init(context);
EmbeddedSocialServiceProvider serviceProvider = new EmbeddedSocialServiceProvider(context);
GlobalObjectRegistry.addObject(EmbeddedSocialServiceProvider.class, serviceProvider);
GlobalObjectRegistry.addObject(new Preferences(context));
GlobalObjectRegistry.addObject(new RequestInfoProvider(context));
GlobalObjectRegistry.addObject(new UserAccount(context));
GlobalObjectRegistry.addObject(new NotificationController(context));
NetworkAvailability networkAccessibility = new NetworkAvailability();
networkAccessibility.startMonitoring(context);
GlobalObjectRegistry.addObject(networkAccessibility);
FacebookSdk.sdkInitialize(context);
FacebookSdk.setApplicationId(options.getFacebookApplicationId());
}
示例2: DaoManager
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
private DaoManager(Context context){
if (helper == null) {
helper = OpenHelperManager.getHelper(context, DataBaseHelper.class);
}
try {
dao_contact = helper.getContactsDao();
dao_userConversation = helper.getUserConversationDao();
dao_session = helper.getSessionDao();
dao_message = helper.getMessageDao();
dao_sessionMember = helper.getSessionMemberDao();
dao_userSession = helper.getUserSessionDao();
dao_timeStamp = helper.getTimeStampDao();
dao_user = helper.getUserDao();
dao_emoji = helper.getEmojiDao();
dao_webValue = helper.getWebValueDao();
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: onCreate
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
database = OpenHelperManager.getHelper(this, DatabaseHelper.class);
// Set the custom toolbar
final Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setLogo(R.mipmap.ic_launcher);
floatingButton = (FloatingActionButton) findViewById(R.id.floatingButton);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction().add(R.id.container, new ServersListFragment()).commit();
}
getFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
shouldDisplayNavigateUp();
}
});
shouldDisplayNavigateUp();
}
示例4: doInBackground
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
ArrayList<Track> mTrackList = Utils.musicLoader(mContext);
OrmHandler ormHandler = OpenHelperManager.getHelper(mContext, OrmHandler.class);
try {
Dao<Track, String> dbTrack = ormHandler.getDao(Track.class);
List<Track> _temp = dbTrack.queryForAll();
_temp.removeAll(mTrackList);
for (Track t :
mTrackList) {
dbTrack.createIfNotExists(t);
}
dbTrack.delete(_temp);
} catch (SQLException e) {
e.printStackTrace();
}
OpenHelperManager.releaseHelper();
return null;
}
示例5: bucketOps
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
public static void bucketOps(String path, Boolean bucket, Context mContext) {
final OrmHandler ormHandler = OpenHelperManager.getHelper(mContext, OrmHandler.class);
try {
Dao<Track, String> dbTrack = ormHandler.getDao(Track.class);
QueryBuilder<Track, String> queryBuilder = dbTrack.queryBuilder();
SelectArg selectArg = new SelectArg();
queryBuilder.where().eq("path", selectArg);
PreparedQuery<Track> preparedQuery = queryBuilder.prepare();
selectArg.setValue(path);
List<Track> lister = dbTrack.query(preparedQuery);
Track temp_track = lister.get(0);
temp_track.setBucket(bucket);
dbTrack.update(temp_track);
BUCKET_OPS = true;
} catch (SQLException | IndexOutOfBoundsException e) {
e.printStackTrace();
}
}
示例6: onCreate
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// This is here because onStart is not called when BIND_AUTO_CREATE is used
mContext = this;
localBroadcastManager = LocalBroadcastManager.getInstance(this);
final OrmHandler ormHandler = OpenHelperManager.getHelper(this, OrmHandler.class);
Dao<Track, String> dbTrack;
try {
dbTrack = ormHandler.getDao(Track.class);
mTrackList = dbTrack.queryForAll();
mBucketList = dbTrack.queryForEq("bucket", true);
} catch (SQLException e) {
e.printStackTrace();
}
}
示例7: getDiaryTalks
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
public static List<Talk> getDiaryTalks(Context context){
DataBaseHelper dataBaseHelper = OpenHelperManager.getHelper(context, DataBaseHelper.class);
try {
QueryBuilder<Talk, String> builder = dataBaseHelper.getTalkDao().queryBuilder();
builder.orderBy("order",true);
Where<Talk,String> where = builder.where();
where.eq("scheduled", true);
List<Talk> talkList = builder.query();
if(!talkList.isEmpty() && talkList!=null) {
return talkList;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
示例8: onCreate
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Timber.plant(new CrashlyticsTree());
}
registerActivityLifecycleCallbacks( new LifecycleHandler() );
OpenHelperManager.setOpenHelperClass(DatabaseHelper.class);
RoboGuice.getOrCreateBaseApplicationInjector(
this,
RoboGuice.DEFAULT_STAGE,
RoboGuice.newDefaultRoboModule(this),
new ServerModule());
}
示例9: searchMangaByCover
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
private static Manga searchMangaByCover(String cover){
DatabaseHelper dbs = OpenHelperManager.getHelper(
App.getInstance().getApplicationContext(),
DatabaseHelper.class);
Manga manga = null;
try {
manga = dbs.getMangaRunDao().queryBuilder().where().eq(Manga.COVER_COLUMN_NAME, cover)
.queryForFirst();
} catch (SQLException e) {
e.printStackTrace();
} finally {
OpenHelperManager.releaseHelper();
}
return manga;
}
示例10: cancelAllAlarms
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
private void cancelAllAlarms()
{
UpdateAlarmsService.cancelAutoUpdateAlarm( m_context );
final DatabaseHelper databaseHelper = OpenHelperManager.getHelper( m_context, DatabaseHelper.class );
if( databaseHelper != null )
{
try
{
final Dao<Launch, Integer> launchDao = databaseHelper.getDao( Launch.class );
for( final Launch launch : launchDao )
{
UpdateAlarmsService.cancelAlarmsForLaunch( launch, m_context );
}
}
catch( SQLException e )
{
e.printStackTrace();
}
OpenHelperManager.releaseHelper();
}
}
示例11: doInBackground
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
@Override
protected Launch doInBackground( final Integer... ids )
{
Launch launch = null;
if( m_context != null )
{
final DatabaseHelper databaseHelper = OpenHelperManager.getHelper( m_context, DatabaseHelper.class );
if( databaseHelper != null )
{
try
{
Dao<Launch, Integer> launchDao = databaseHelper.getDao( Launch.class );
launch = launchDao.queryForId( ids[ 0 ] );
}
catch( final SQLException e )
{
e.printStackTrace();
}
OpenHelperManager.releaseHelper();
}
}
return launch;
}
示例12: cleanUpOldLaunches
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
private void cleanUpOldLaunches()
{
final DatabaseHelper databaseHelper = OpenHelperManager
.getHelper( LaunchUpdateService.this, DatabaseHelper.class );
if( databaseHelper != null )
{
try
{
final Dao<Launch, Integer> launchDao = databaseHelper.getDao( Launch.class );
DeleteBuilder<Launch, Integer> builder = launchDao.deleteBuilder();
builder.where().lt( "net", getOldLaunchThreshold() );
launchDao.delete( builder.prepare() );
}
catch( final SQLException e )
{
e.printStackTrace();
}
finally
{
OpenHelperManager.releaseHelper();
}
}
}
示例13: getDataPieces
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
/**
* Returns all the DataPieces currently within the application's database.
*
* @param {@link Context}
* @return a {@link List} of the {@link DataPiece}s within the database.
*/
public static List<DataPiece> getDataPieces(final Context context) {
final ResilienceDbHelper dBHelper = getDbHelper(context);
List<DataPiece> pieces = null;
try {
final Dao<DataPiece, String> dao = dBHelper.getDataPieceDao();
pieces = dao.queryForAll();
} catch (SQLException e) {
if (Flags.DEBUG) {
Log.e(ResilienceDbManager.class.getSimpleName(), e.getMessage());
}
} finally {
OpenHelperManager.releaseHelper();
}
return pieces;
}
示例14: persistDataPiece
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
/**
* @param context
* @param dataPiece
*/
public static void persistDataPiece(final Context context, final DataPiece dataPiece) {
final ResilienceApplication resilApp = (ResilienceApplication) context.getApplicationContext();
resilApp.getDatabaseThreadExecutorService().execute(new Runnable() {
@Override
public void run() {
final ResilienceDbHelper dbHelper = getDbHelper(context);
try {
final Dao<DataPiece, String> pieceDao = dbHelper.getDataPieceDao();
pieceDao.createOrUpdate(dataPiece);
} catch (Exception e) {
} finally {
OpenHelperManager.releaseHelper();
}
}
});
}
示例15: getDao
import com.j256.ormlite.android.apptools.OpenHelperManager; //导入依赖的package包/类
public static <T, ID> Dao<T, ID> getDao(Context context, Class<T> t) {
Dao<T, ID> dao = null;
try {
dao = ((DatabaseHelper) OpenHelperManager.getHelper(context,
DatabaseHelper.class)).getDao(t);
} catch (SQLException e) {
e.printStackTrace();
}
Log.i(DBFactory.class.getSimpleName(), "SqliteDao");
return dao;
}