Java Code Examples for com.tencent.mmkv.MMKV#mmkvWithID()
The following examples show how to use
com.tencent.mmkv.MMKV#mmkvWithID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BenchmarkManager.java From FastSharedPreferences with Apache License 2.0 | 5 votes |
private long mmkvBatchWriteInt() { RunTimer.start(); Random rand = new Random(); MMKV mmkv = MMKV.mmkvWithID(MMKV_ID, MMKV.SINGLE_PROCESS_MODE, null); for (int i = 0; i < LOOPS; i++) { String key = i + ""; int value = rand.nextInt(); mmkv.encode(key, value); } long cost = RunTimer.end(); return cost; }
Example 2
Source File: BenchmarkManager.java From FastSharedPreferences with Apache License 2.0 | 5 votes |
private long mmkvBatchReadInt() { RunTimer.start(); MMKV mmkv = MMKV.mmkvWithID(MMKV_ID, MMKV.SINGLE_PROCESS_MODE, null); for (int i = 0; i < LOOPS; i++) { String key = i + ""; int tmp = mmkv.getInt(key, -1); } long cost = RunTimer.end(); return cost; }
Example 3
Source File: MainActivity.java From DevUtils with Apache License 2.0 | 4 votes |
/** * MMKV 简单使用 */ private void mmkvSimple() { MMKV defaultMMKV = MMKV.defaultMMKV(); String mmapID = defaultMMKV.mmapID(); defaultMMKV.putString(KeyConstants.Common.KEY_DATA, "defaultMMKV 存储数据"); String data = defaultMMKV.getString(KeyConstants.Common.KEY_DATA, null); MMKV tempMMKV = MMKV.mmkvWithID("temp"); String tempData = tempMMKV.getString(KeyConstants.Common.KEY_DATA, null); MMKV mmapIDMMKV = MMKV.mmkvWithID(mmapID); String mmapIdData = mmapIDMMKV.getString(KeyConstants.Common.KEY_DATA, null); StringBuilder builder = new StringBuilder(); builder.append("default MMKV") .append(StringUtils.NEW_LINE_STR) .append("\t\tmmapID: " + mmapID) .append(StringUtils.NEW_LINE_STR) .append("\t\tdata: " + data); builder.append(StringUtils.NEW_LINE_STR) .append(StringUtils.NEW_LINE_STR); builder.append("temp MMKV") .append(StringUtils.NEW_LINE_STR) .append("\t\tmmapID: " + tempMMKV.mmapID()) .append(StringUtils.NEW_LINE_STR) .append("\t\tdata: " + tempData); builder.append(StringUtils.NEW_LINE_STR) .append(StringUtils.NEW_LINE_STR); builder.append("mmapID MMKV") .append(StringUtils.NEW_LINE_STR) .append("\t\tmmapID: " + mmapIDMMKV.mmapID()) .append(StringUtils.NEW_LINE_STR) .append("\t\tdata: " + mmapIdData); DevLogger.dTag(mTag, builder.toString()); }