本文整理汇总了Java中android.content.SharedPreferences.getAll方法的典型用法代码示例。如果您正苦于以下问题:Java SharedPreferences.getAll方法的具体用法?Java SharedPreferences.getAll怎么用?Java SharedPreferences.getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.SharedPreferences
的用法示例。
在下文中一共展示了SharedPreferences.getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkForWallets
import android.content.SharedPreferences; //导入方法依赖的package包/类
public void checkForWallets(Context c) {
// Full wallets
File[] wallets = c.getFilesDir().listFiles();
if (wallets == null) {
return;
}
for (int i = 0; i < wallets.length; i++) {
if (wallets[i].isFile()) {
if (wallets[i].getName().length() == 40) {
add(new FullWallet("0x" + wallets[i].getName(), wallets[i].getName()), c);
}
}
}
// Watch only
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c);
Map<String, ?> allEntries = preferences.getAll();
for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
if (entry.getKey().length() == 42 && !mapdb.contains(entry.getKey()))
add(new WatchWallet(entry.getKey()), c);
}
if (mapdb.size() > 0)
save(c);
}
示例2: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 返回所有的键值对
*
* @param context
* @return
*/
public static Map<String, ?> getAll(Context context)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.getAll();
}
示例3: migrate
import android.content.SharedPreferences; //导入方法依赖的package包/类
private void migrate() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
Map<String, ?> passwords = pref.getAll();
for (String key : passwords.keySet()) {
if (key.contains("-pwd")) {
String address = key.replace("-pwd", "");
try {
KS.put(context, address.toLowerCase(), PasswordManager.getPassword(address, context));
} catch (Exception ex) {
Toast.makeText(context, "Could not process passwords.", Toast.LENGTH_LONG)
.show();
ex.printStackTrace();
}
}
}
}
示例4: doInBackground
import android.content.SharedPreferences; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
SharedPreferences sp = CacheHelper.getPreferences(CacheHelper.FAV);
Map<String, ?> map = sp.getAll();
for (Map.Entry<String, ?> entry : map.entrySet()) {
if (entry.getValue() instanceof Integer) {
Integer testId = (Integer) entry.getValue();
mData.add(readTestCache(testId));
}
}
return null;
}
示例5: getAllNotes
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static List<Note> getAllNotes(Context context) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
List<Note> noteList = new ArrayList<>();
Map<String, ?> key = sharedPreferences.getAll();
for (Map.Entry<String, ?> entry : key.entrySet()) {
String savedValue = (String) entry.getValue();
if (savedValue != null) {
Note note = new Note(entry.getKey(), savedValue);
noteList.add(note);
}
}
return noteList;
}
示例6: getAllEntries
import android.content.SharedPreferences; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private List<Map.Entry<String, Integer>> getAllEntries(Context context) {
final SharedPreferences preferences = getSharedPreferences(context);
final Map<String, ?> allPreferences = preferences.getAll();
return DictionaryUtil.sortHashMapByValues((HashMap<String, Integer>) allPreferences);
}
示例7: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 返回所有的键值对
*
* @return
*/
public static Map<String, ?> getAll()
{
SharedPreferences sp = ContextHolder.getContext().getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.getAll();
}
示例8: detectGpsMode
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static boolean detectGpsMode(SharedPreferences preferences) {
Map<String, ?> prefs = preferences.getAll();
Boolean mode = (Boolean) prefs.get(PREF_GPS_MODE);
if (mode == null) {
// detect default mode
mode = Constants.SDK_VERSION < 9; // true - allowed
if (DEBUG) {
Log.d(TAG, "Detected " + PREF_GPS_MODE + " " + mode);
}
// update preferences
Editor editor = preferences.edit();
editor.putBoolean(PREF_GPS_MODE, mode).commit();
}
return mode;
}
示例9: SampleContentDb
import android.content.SharedPreferences; //导入方法依赖的package包/类
private SampleContentDb(Context context) {
mContext = context.getApplicationContext();
SharedPreferences sampleLocalDbPrefs = mContext.getSharedPreferences(SAMPLE_LOCAL_DB,
Context.MODE_PRIVATE);
// Creating a copy of the set instance returned by getStringSet since the consistency of the
// stored data is not guaranteed if the content is modified according to the docs.
Set<String> removedClips = sampleLocalDbPrefs.getStringSet(REMOVED_CLIPS_KEY,
new HashSet<String>());
mRemovedClips = new HashSet<>(removedClips);
SharedPreferences clipsProgressPrefs = context.getSharedPreferences(CLIPS_PROGRESS_DB,
Context.MODE_PRIVATE);
Map<String, Long> clipsProgress = (Map<String, Long>) clipsProgressPrefs.getAll();
mClipsProgress = new HashMap<>(clipsProgress);
}
示例10: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 返回所有的键值对
*/
public static Map<String,?> getAll(Context context){
SharedPreferences sp = context.getSharedPreferences(getSpName(context),Context.MODE_PRIVATE);
return sp.getAll();
}
示例11: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* Get all the shared preferences as a map of strings and objects (will need to be casted)
*/
public static Map<String, ?> getAll(Context context) {
SharedPreferences settings = context.getSharedPreferences(PREF_FILE, 0);
return settings.getAll();
}
示例12: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static Map<String, ?> getAll(Context context, String fileName) {
SharedPreferences sp = SharedPreferencesImpl.getSharedPreferences(context, getFileName(fileName),
Context.MODE_PRIVATE);
return sp.getAll();
}
示例13: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
public static Map<String, ?> getAll(Context context, String spName) {
SharedPreferences sp = context.getSharedPreferences(spName,
Context.MODE_PRIVATE);
return sp.getAll();
}
示例14: getAll
import android.content.SharedPreferences; //导入方法依赖的package包/类
/**
* 返回所有的键值对
*
* @return
*/
public static Map<String, ?> getAll() {
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.getAll();
}
示例15: getAllMap
import android.content.SharedPreferences; //导入方法依赖的package包/类
public Map<String, Object> getAllMap() {
SharedPreferences sharePre = ctx.getSharedPreferences(FileName,
Context.MODE_PRIVATE);
return (Map<String, Object>) sharePre.getAll();
}