当前位置: 首页>>代码示例>>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;未经允许,请勿转载。