本文整理汇总了Java中com.snappydb.DB类的典型用法代码示例。如果您正苦于以下问题:Java DB类的具体用法?Java DB怎么用?Java DB使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DB类属于com.snappydb包,在下文中一共展示了DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: whenDefaultGifsAreLoaded
import com.snappydb.DB; //导入依赖的package包/类
@Test
public void whenDefaultGifsAreLoaded() {
try {
DB db = DBFactory.open(getTargetContext());
db.destroy();
} catch (Exception e) {
Log.e("TEST", e.getLocalizedMessage(), e);
}
mHelper.dispatchFakeAppState(ImmutableAppState.builder().build());
mHelper.replacePersistenceMiddleware(new DataManager(getTargetContext()));
GifActionCreator.getInstance().setDispatcher(mock(DispatcherImpl.class));
mActivityTestRule.launchActivity(new Intent());
Map<String, Gif> expectedGifs = getAppStateDefault().getGifs();
RecyclerTestLocker locker = new RecyclerTestLocker(getRecyclerView(), expectedGifs.size());
locker.waitForEspresso();
Map<Strings, Gif> gotGifs = ((GifsAdapter) getRecyclerView().getAdapter()).getGifs();
assertEquals(expectedGifs, gotGifs);
GifActionCreator.getInstance().setDispatcher(getFluxxan().getDispatcher());
}
示例2: snappydbExecute
import com.snappydb.DB; //导入依赖的package包/类
/**
* @param context Context
* @param dbName String
* @param updateOperation SnappyDBUpdateOperation
*/
public static void snappydbExecute(Context context, String dbName, SnappyDBUpdateOperation updateOperation) {
DB snappydb = null;
try {
snappydb = DBFactory.open(context, dbName);
updateOperation.update(snappydb);
snappydb.close();
} catch (SnappydbException e) {
Log.e(TAG, e.getLocalizedMessage());
try {
if (snappydb != null && snappydb.isOpen() ) {
snappydb.close();
}
} catch (SnappydbException e1) {
Log.e(TAG, e.getLocalizedMessage());
}
}
}
示例3: savePinnedApps
import com.snappydb.DB; //导入依赖的package包/类
public void savePinnedApps () throws SnappydbException
{
/*
SharedPreferences prefs = this.getContext ().getSharedPreferences ("pinned", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit ();
editor.clear ();
for (int i = 0; i < this.pinned.size (); i++)
{
App app = this.pinned.get (i);
StringBuilder packageAndActivityName = new StringBuilder (app.getPackageName ())
.append ("\n")
.append (app.getActivityName ());
editor.putString (Integer.toString (i), packageAndActivityName.toString ());
}
editor.apply ();*/
DB db = DBFactory.open (this.getContext ());
db.put ("launcher_pinnedApps", this.pinned.toArray ());
db.close ();
this.parent.pinnedAppsChanged ();
}
示例4: onClick
import com.snappydb.DB; //导入依赖的package包/类
@Override
public void onClick(View v) {
new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.guillotine_hamburger), contentHamburger)
.setStartDelay(RIPPLE_DURATION)
.setActionBarViewForAnimation(toolbar)
.setClosedOnStart(true)
.build();
switch (v.getId())
{
case R.id.activity_group:
Toast.makeText(this,"My Events",Toast.LENGTH_SHORT).show();
break;
case R.id.feed_group:
Intent intent2=new Intent(HomeActivity.this,FeedActivity.class);
startActivity(intent2);
break;
case R.id.profile_group:
Intent intent1=new Intent(HomeActivity.this,ProfileActivity.class);
startActivity(intent1);
break;
case R.id.settings_group:
LogSaver.appendLog("Facebook Logged Out :"+LoginManager.getInstance());
LoginManager.getInstance().logOut();
try {
DB db = DBFactory.open(getApplicationContext(), "users");
db.destroy();
db.close();
}
catch (SnappydbException e){e.printStackTrace();}
Intent intent=new Intent(HomeActivity.this,MainActivity.class);
startActivity(intent);
finish();
LogSaver.appendLog("Facebook Logged Out");
break;
}
}
示例5: getAppStateFromDB
import com.snappydb.DB; //导入依赖的package包/类
private AppState getAppStateFromDB() {
AppState appstate = null;
try {
DB db = DBFactory.open(getTargetContext());
appstate = AppState.fromJson(db.get(TAG_APP_STATE));
db.close();
} catch (SnappydbException | IOException e) {
Log.e(getClass().getSimpleName(), "error", e);
}
return appstate;
}
示例6: saveAppState
import com.snappydb.DB; //导入依赖的package包/类
private void saveAppState(AppState appState) {
try {
DB db = DBFactory.open(getTargetContext());
db.put(TAG_APP_STATE, appState.toJson());
db.close();
} catch (SnappydbException | IOException e) {
Log.e(getClass().getSimpleName(), "error", e);
}
}
示例7: checkForNonNull
import com.snappydb.DB; //导入依赖的package包/类
private DB checkForNonNull(DB pSnappyDatabase) throws SnappydbException {
if (pSnappyDatabase == null) {
throw new UnsupportedSnappyDb();
} else {
return pSnappyDatabase;
}
}
示例8: clear
import com.snappydb.DB; //导入依赖的package包/类
@Override
public void clear() {
try {
DB db = new SnappyDB.Builder(context).name(fileName).build();
db.destroy();
} catch (SnappydbException e) {
Log.w("SnappySweeper", "Can't clear db", e);
}
}
示例9: saveEnabledLenses
import com.snappydb.DB; //导入依赖的package包/类
public void saveEnabledLenses () throws SnappydbException
{
DB db = DBFactory.open (this.context);
List<String> enabledLenses = new ArrayList<String> ();
for (int j = 0; j < this.enabled.size (); j++)
enabledLenses.add (this.enabled.get (j).getClass ().getSimpleName ());
db.put ("dash_enabledLenses", enabledLenses);
db.close ();
}
示例10: getCachDB
import com.snappydb.DB; //导入依赖的package包/类
public DB getCachDB() {
return cachDB;
}
示例11: getAppState
import com.snappydb.DB; //导入依赖的package包/类
public AppState getAppState() throws SnappydbException, IOException {
DB db = DBFactory.open(mContext);
AppState appState = AppState.fromJson(db.get(TAG_APP_STATE));
db.close();
return appState;
}
示例12: saveAppState
import com.snappydb.DB; //导入依赖的package包/类
public void saveAppState(AppState appState) throws SnappydbException, JsonProcessingException {
DB db = DBFactory.open(mContext);
db.put(TAG_APP_STATE, appState.toJson());
db.close();
}
示例13: cleanup
import com.snappydb.DB; //导入依赖的package包/类
@After
public void cleanup() throws SnappydbException {
DB db = DBFactory.open(getTargetContext());
db.destroy();
}
示例14: RxSnappyClient
import com.snappydb.DB; //导入依赖的package包/类
public RxSnappyClient(DB db) {
super(db);
}
示例15: BaseSnappyClient
import com.snappydb.DB; //导入依赖的package包/类
public BaseSnappyClient(DB db) {
this.db = db;
if (this.db == null) {
throw new RxSnappyException("Database is null!");
}
}