本文整理汇总了Java中com.snappydb.DB.close方法的典型用法代码示例。如果您正苦于以下问题:Java DB.close方法的具体用法?Java DB.close怎么用?Java DB.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.snappydb.DB
的用法示例。
在下文中一共展示了DB.close方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
示例2: 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 ();
}
示例3: 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;
}
}
示例4: 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;
}
示例5: 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);
}
}
示例6: 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 ();
}
示例7: 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;
}
示例8: 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();
}
示例9: LensManager
import com.snappydb.DB; //导入方法依赖的package包/类
public LensManager (Context context, LinearLayout llDashHomeAppsContainer, LinearLayout llDashHomeLensesContainer, ProgressWheel pwDashSearchProgress, AppManager apps) throws SnappydbException
{
this.context = context;
this.enabled = new ArrayList<Lens> ();
this.llDashHomeAppsContainer = llDashHomeAppsContainer;
this.llDashHomeLensesContainer = llDashHomeLensesContainer;
if (llDashHomeAppsContainer != null)
this.lvDashHomeLensResults = (ListView) llDashHomeLensesContainer.findViewById (R.id.lvDashHomeLensResults);
this.pwDashSearchProgress = pwDashSearchProgress;
SharedPreferences prefs = this.context.getSharedPreferences ("prefs", Context.MODE_PRIVATE);
DB db = DBFactory.open (this.context);
if (apps != null)
context = apps.getContext ();
this.lenses.put ("AskUbuntu", new AskUbuntu (context));
this.lenses.put ("DuckDuckGo", new DuckDuckGo (context));
this.lenses.put ("GitHub", new GitHub (context));
this.lenses.put ("GooglePlus", new GooglePlus (context));
this.lenses.put ("InstalledApps", new InstalledApps (context, apps));
this.lenses.put ("LocalFiles", new LocalFiles (context)); // LocalFiles needs to show an AlertDialog in some cases, thus it needs the activity's Context (which AppsManager has) in stead of the Application Context (this.context). //
this.lenses.put ("Reddit", new Reddit (context));
this.lenses.put ("ServerFault", new ServerFault (context));
this.lenses.put ("StackOverflow", new StackOverflow (context));
this.lenses.put ("SuperUser", new SuperUser (context));
List<String> defaultLenses = new ArrayList<String> ();
defaultLenses.add ("InstalledApps");
defaultLenses.add ("LocalFiles");
List<String> enabledLenses;
if (db.exists ("dash_enabledLenses"))
{
enabledLenses = db.get ("dash_enabledLenses", ArrayList.class);
}
else
{
enabledLenses = new ArrayList<String> ();
enabledLenses.addAll (defaultLenses);
}
for (String lensName : enabledLenses)
{
Lens lens = this.lenses.get (lensName);
if (lens != null && (! this.isLensEnabled (lens)))
this.enabled.add (lens);
}
db.close ();
this.maxResultsPerLens = Integer.valueOf (prefs.getString ("dashsearch_lenses_maxresults", "10"));
}