本文整理了Java中android.content.Context.moveSharedPreferencesFrom()
方法的一些代码示例,展示了Context.moveSharedPreferencesFrom()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.moveSharedPreferencesFrom()
方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:moveSharedPreferencesFrom
暂无
代码示例来源:origin: oasisfeng/condom
@RequiresApi(N) @Override public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
return mBase.moveSharedPreferencesFrom(sourceContext, name);
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = N)
public void testMoveSharedPreferencesFrom() throws Exception {
String PREFS = "PREFS";
String PREF_NAME = "TOKEN_PREF";
context
.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.edit()
.putString(PREF_NAME, "token")
.commit();
Context dpContext = context.createDeviceProtectedStorageContext();
assertThat(dpContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).contains(PREF_NAME))
.isFalse();
assertThat(context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).contains(PREF_NAME))
.isTrue();
assertThat(dpContext.moveSharedPreferencesFrom(context, PREFS)).isTrue();
assertThat(dpContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE).contains(PREF_NAME))
.isTrue();
assertThat(context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).contains(PREF_NAME))
.isFalse();
}
代码示例来源:origin: Trumeet/MiPushFramework
@RequiresApi(N) @Override public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
return mBase.moveSharedPreferencesFrom(sourceContext, name);
}
内容来源于网络,如有侵权,请联系作者删除!