當前位置: 首頁>>代碼示例>>Java>>正文


Java Editor.apply方法代碼示例

本文整理匯總了Java中android.content.SharedPreferences.Editor.apply方法的典型用法代碼示例。如果您正苦於以下問題:Java Editor.apply方法的具體用法?Java Editor.apply怎麽用?Java Editor.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.SharedPreferences.Editor的用法示例。


在下文中一共展示了Editor.apply方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setValue

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * Set value method
 * @param context
 * @param key
 * @param value
 * @param secure
 * @throws NoSuchAlgorithmException
 */
private static void setValue(@NonNull Context context, @NonNull String key, @NonNull String value, @NonNull Boolean secure) throws NoSuchAlgorithmException {
    SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    Editor editor = settings.edit();

    // Check if current Android version is Nougat or higher. If so, hash key and hash value, if needed.
    // Otherwise, use the raw key and value due to limitations by previous Android versions. Albeit this is not ideal, it is not really insecure due the fact
    // notes are encrypted by an unknown password provided by the user. Nevertheless, it is possible to see the current keys.
    // TODO: create a way so keys are always encrypted.
    if(isVersionNougatOrHigher()) {
        key = EncryptionHandler.hashString(key);
        value = secure ? EncryptionHandler.hashString(value) : value;
    }

    editor.putString(key, value);
    editor.apply();
}
 
開發者ID:YoeriNijs,項目名稱:NoteBuddy,代碼行數:25,代碼來源:KeyValueDB.java

示例2: initRecord

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private void initRecord(Context context) {
    this.mPreferences = context.getSharedPreferences(DOWNLOAD_RECORD, 0);
    this.recordMap = (Map) FastJsonUtils.fromJson(this.mPreferences.getString(CacheKey
            .DOWNLOAD_RECORD, null), new TypeReference<Map<String, DownloadRecord>>() {
    });
    if (this.recordMap == null) {
        String oldRecord = FileCache.get(context, DOWNLOAD_RECORD).getAsString(CacheKey
                .DOWNLOAD_RECORD);
        this.recordMap = (Map) FastJsonUtils.fromJson(oldRecord, new
                TypeReference<Map<String, DownloadRecord>>() {
        });
        if (this.recordMap == null) {
            this.recordMap = new HashMap();
            return;
        }
        Editor editor = this.mPreferences.edit();
        editor.putString(CacheKey.DOWNLOAD_RECORD, oldRecord);
        editor.apply();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:21,代碼來源:DownloadHelper.java

示例3: a

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void a(String str, boolean z) {
    if (N() != null) {
        Editor edit = N().edit();
        edit.putBoolean(str, z);
        edit.apply();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:8,代碼來源:m.java

示例4: putStringProcess

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void putStringProcess(String key, String value)
{

    SharedPreferences sharedPreferences = HeroVideoApp.getInstance().getSharedPreferences("preference_mu", Context.MODE_MULTI_PROCESS);
    Editor editor = sharedPreferences.edit();
    editor.putString(key, value);
    editor.apply();
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:9,代碼來源:PreferenceUtil.java

示例5: putInt

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private static void putInt(String key, int value) {

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
        BilibiliApp.getInstance());
    Editor editor = sharedPreferences.edit();
    editor.putInt(key, value);
    editor.apply();
  }
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:9,代碼來源:PreferenceUtil.java

示例6: clear

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void clear(Context context, String fileName) {
    SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
            Context.MODE_PRIVATE);
    Editor editor = sp.edit();
    editor.clear();
    editor.apply();
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:8,代碼來源:SPUtils.java

示例7: c

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
protected static void c(String str, String str2) {
    if (a != null) {
        Editor edit = a.edit();
        edit.putString(str, str2);
        edit.apply();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:f.java

示例8: setIncludeDeviceInfoPreference

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void setIncludeDeviceInfoPreference(Context context, boolean value) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);

    Editor editor = sharedPrefs.edit();
    editor.putBoolean(context.getString(R.string.pref_include_device_info), value);
    editor.apply();
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:8,代碼來源:PreferenceHelper.java

示例9: putBoolean

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void putBoolean(String key, boolean value) {

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
        BilibiliApp.getInstance());
    Editor editor = sharedPreferences.edit();
    editor.putBoolean(key, value);
    editor.apply();
  }
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:9,代碼來源:PreferenceUtil.java

示例10: write

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void write(Context context, String fileName, String k,
        String v) {
    SharedPreferences preference = context.getSharedPreferences(fileName,
            Context.MODE_PRIVATE);
    Editor editor = preference.edit();
    editor.putString(k, v);
    editor.apply();
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:9,代碼來源:PreferenceHelper.java

示例11: setChangeLogSeen

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private void setChangeLogSeen() throws NameNotFoundException {
    Context context = shadowApplication.getApplicationContext();
    PackageInfo packageInfo = context.getPackageManager().getPackageInfo(
            context.getPackageName(), 0);
    Editor editor = PreferenceManager.getDefaultSharedPreferences(shadowApplication.getApplicationContext())
            .edit();
    editor.putInt("ckChangeLog_last_version_code", packageInfo.versionCode);
    editor.apply();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:10,代碼來源:AccountsTest.java

示例12: 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();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:11,代碼來源:af.java

示例13: setArtistDetailSongSortOrder

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setArtistDetailSongSortOrder(String sortOrder) {
    Editor edit = this.mPreferences.edit();
    edit.putString(ARTIST_DETAIL_SONG_SORT_ORDER, sortOrder);
    edit.apply();
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:6,代碼來源:PreferenceUtil.java

示例14: setConntectedVpnProfileDisconnected

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void setConntectedVpnProfileDisconnected(Context c) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
    Editor prefsedit = prefs.edit();
    prefsedit.putString(LAST_CONNECTED_PROFILE, null);
    prefsedit.apply();
}
 
開發者ID:akashdeepsingh9988,項目名稱:Cybernet-VPN,代碼行數:7,代碼來源:ProfileManager.java

示例15: removePreference

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private static void removePreference(Context context, String prefKey) {
    Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.remove(prefKey);
    editor.apply();
}
 
開發者ID:dvdciri,項目名稱:DeepImagePreview-Project,代碼行數:6,代碼來源:Prefs.java


注:本文中的android.content.SharedPreferences.Editor.apply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。