本文整理汇总了Java中android.content.SharedPreferences.Editor.putInt方法的典型用法代码示例。如果您正苦于以下问题:Java Editor.putInt方法的具体用法?Java Editor.putInt怎么用?Java Editor.putInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences.Editor
的用法示例。
在下文中一共展示了Editor.putInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveVersionCode
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void saveVersionCode() {
Context context = getContext();
if (context != null) {
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context
.getPackageName(), 0);
if (packageInfo != null) {
Editor edit = context.getSharedPreferences("openSdk.pref", 0).edit();
edit.putInt("app.vercode", packageInfo.versionCode);
edit.commit();
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
}
示例2: getAccountIdForCallHandler
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Retrieve internal id of call handler as saved in databases It should be
* some negative < SipProfile.INVALID_ID number
*
* @param ctxt Application context
* @param packageName name of the call handler package
* @return the id of this call handler in databases
*/
public static Long getAccountIdForCallHandler(Context ctxt, String packageName) {
SharedPreferences prefs = ctxt.getSharedPreferences("handlerCache", Context.MODE_PRIVATE);
long accountId = SipProfile.INVALID_ID;
try {
accountId = prefs.getLong(VIRTUAL_ACC_PREFIX + packageName, SipProfile.INVALID_ID);
} catch (Exception e) {
Log.e(THIS_FILE, "Can't retrieve call handler cache id - reset");
}
if (accountId == SipProfile.INVALID_ID) {
// We never seen this one, add a new entry for account id
int maxAcc = prefs.getInt(VIRTUAL_ACC_MAX_ENTRIES, 0x0);
int currentEntry = maxAcc + 1;
accountId = SipProfile.INVALID_ID - (long) currentEntry;
Editor edt = prefs.edit();
edt.putLong(VIRTUAL_ACC_PREFIX + packageName, accountId);
edt.putInt(VIRTUAL_ACC_MAX_ENTRIES, currentEntry);
edt.commit();
}
return accountId;
}
示例3: put
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* 存放object
*
* @param context
* @param fileName
* @param key
* @param object
* @return
*/
public static boolean put(Context context, String fileName, String key, Object object) {
SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
Editor editor = sp.edit();
if (object instanceof String) {
editor.putString(key, (String) object);
} else if (object instanceof Integer) {
editor.putInt(key, ((Integer) object).intValue());
} else if (object instanceof Boolean) {
editor.putBoolean(key, ((Boolean) object).booleanValue());
} else if (object instanceof Float) {
editor.putFloat(key, ((Float) object).floatValue());
} else if (object instanceof Long) {
editor.putLong(key, ((Long) object).longValue());
} else if (object instanceof Set) {
editor.putStringSet(key, (Set<String>) object);
} else {
editor.putStringSet(key, (Set<String>) object);
}
return editor.commit();
}
示例4: isLibExtracted
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
@SuppressLint({"SdCardPath"})
public static boolean isLibExtracted(String str, int i) {
Context context = Global.getContext();
if (context == null) {
f.c(a, "-->isSecureLibExtracted, global context is null. ");
return false;
}
File file = new File(context.getFilesDir(), str);
SharedPreferences sharedPreferences = context.getSharedPreferences("secure_lib", 0);
if (!file.exists()) {
return false;
}
int i2 = sharedPreferences.getInt("version", 0);
f.c(a, "-->extractSecureLib, libVersion: " + i + " | oldVersion: " + i2);
if (i == i2) {
return true;
}
Editor edit = sharedPreferences.edit();
edit.putInt("version", i);
edit.commit();
return false;
}
示例5: putInt
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void putInt(String key, int value)
{
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(HeroVideoApp.getInstance());
Editor editor = sharedPreferences.edit();
editor.putInt(key, value);
editor.apply();
}
示例6: setDatabasesUpToDate
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
/**
* Remember that all account databases are using the most recent database schema.
*
* @param save
* Whether or not to write the current database version to the
* {@code SharedPreferences} {@link #DATABASE_VERSION_CACHE}.
*
* @see #areDatabasesUpToDate()
*/
public static synchronized void setDatabasesUpToDate(boolean save) {
sDatabasesUpToDate = true;
if (save) {
Editor editor = sDatabaseVersionCache.edit();
editor.putInt(KEY_LAST_ACCOUNT_DATABASE_VERSION, LocalStore.DB_VERSION);
editor.apply();
}
}
示例7: toSharedPreferences
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void toSharedPreferences(SharedPreferences preferences) {
Editor e = preferences.edit();
int count = criterias.size();
e.putString(FILTER_TITLE_PREF, title);
e.putInt(FILTER_LENGTH_PREF, count);
for (int i=0; i<count; i++) {
e.putString(FILTER_CRITERIA_PREF+i, criterias.get(i).toStringExtra());
}
e.putString(FILTER_SORT_ORDER_PREF, getSortOrder());
e.commit();
}
示例8: putAppPrefInt
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void putAppPrefInt(Context context, String prefName, int value) {
if(context!=null){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
Editor edit = sharedPreferences.edit();
edit.putInt(prefName, value);
if(Build.VERSION.SDK_INT>=9){
edit.apply();
}else{
edit.commit();
}
}
}
示例9: clearWarnCounter
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void clearWarnCounter(Context context) {
SharedPreferences props = context.getSharedPreferences(Constants.PREFS_RUNTIME, Context.MODE_WORLD_WRITEABLE);
Editor editor = props.edit();
editor.putInt(PREF_WARN_COUNT, 0);
editor.commit();
}
示例10: on_save_contact
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
@Override
public void on_save_contact(int acc_id, pj_str_t contact, int expires) {
long db_acc_id = PjSipService.getAccountIdForPjsipId(mCtxt, acc_id);
String key_expires = REG_EXPIRES_PREFIX + Long.toString(db_acc_id);
String key_uri = REG_URI_PREFIX + Long.toString(db_acc_id);
Editor edt = prefs_db.edit();
edt.putString(key_uri, PjSipService.pjStrToString(contact));
int now = (int) Math.ceil(System.currentTimeMillis() / 1000.0);
edt.putInt(key_expires, now + expires);
// TODO : have this asynchronous
edt.commit();
}
示例11: a
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void a(Context context, String str, int i) {
if (a(context)) {
b(context);
Editor edit = a.edit();
edit.putInt(str, i);
edit.apply();
return;
}
z.d();
}
示例12: saveConfiguration
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static void saveConfiguration(Context context, int appWidgetId, int mode) {
if (DBG) Log.d(TAG, "saveConfiguration for id=" + appWidgetId + " mode=" + mode);
Editor ed = PreferenceManager.getDefaultSharedPreferences(context).edit();
// Save a specific configuration for this widget id
ed.putInt(getSharedPreferencesKeyMode(appWidgetId), mode);
// Apply() is asynchronous, thus faster than commit() which may be blocking
ed.apply();
}
示例13: getWarnCount
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
private static int getWarnCount(Context context) {
SharedPreferences props = context.getSharedPreferences(Constants.PREFS_RUNTIME, Context.MODE_WORLD_WRITEABLE);
int count = props.getInt(PREF_WARN_COUNT, 0);
Editor editor = props.edit();
editor.putInt(PREF_WARN_COUNT, ++count);
editor.commit();
return count;
}
示例14: a
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public void a(String str, int i) {
if (N() != null) {
Editor edit = N().edit();
edit.putInt(str, i);
edit.apply();
}
}
示例15: set
import android.content.SharedPreferences.Editor; //导入方法依赖的package包/类
public static void set(String key, int value) {
Editor editor = getPreferences().edit();
editor.putInt(key, value);
SharedPreferencesCompat.EditorCompat.getInstance().apply(editor);
}