com.tencent.mmkv.MMKV Java Examples
The following examples show how to use
com.tencent.mmkv.MMKV.
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: BaseApplication.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 初始化其他 lib */ private void initOthers() { // 初始化 MMKV String rootDir = MMKV.initialize(this); DevLogger.d("MMKV rootDir: " + rootDir); // https://github.com/JessYanCoding/AndroidAutoSize/blob/master/demo-subunits/src/main/java/me/jessyan/autosize/demo/subunits/BaseApplication.java // 可不调用, 默认开启 DP 转换 AutoSizeConfig.getInstance().getUnitsManager() .setSupportDP(true); // 初始化 GreenDao GreenManager.init(this); // // 初始化 OkGo // OkGoUtils.initOkGo(this); }
Example #2
Source File: App.java From 12306XposedPlugin with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); MMKV.initialize(this); registerDatabaseManager(); startService(new Intent(this, ShareService.class)); }
Example #3
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 #4
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 #5
Source File: AppStartActivity.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); String info = BuildConfig.BUILD_TYPE + "-" + BuildConfig.VERSION_NAME; if (BuildConfig.DEBUG) { Toast.makeText(mContext, info, Toast.LENGTH_SHORT).show(); } MMKV.defaultMMKV().putBoolean("running", true); }
Example #6
Source File: MyApplication.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
@Override @DebugLog public void onCreate() { super.onCreate(); Debug.startMethodTracing("sample"); MultiDex.install(this); Stetho.initializeWithDefaults(this); if (BuildConfig.DEBUG) { ARouter.openLog(); ARouter.openDebug(); } ARouter.init(this); Fresco.initialize(this); String dir = MMKV.initialize(this); Log.e("application", "onCreate: mmkv.dir==" + dir); WebView.setWebContentsDebuggingEnabled(true); DoraemonKit.disableUpload(); DoraemonKit.install(this); // DoraemonKit.hide(); logLifeCycleCallBacks(); Debug.stopMethodTracing(); }
Example #7
Source File: PerformanceApp.java From android-performance with MIT License | 4 votes |
@Override public void onCreate() { super.onCreate(); MMKV.initialize(PerformanceApp.this); MMKV.defaultMMKV().encode("times",100); int times = MMKV.defaultMMKV().decodeInt("times"); LaunchTimer.startRecord(); mApplication = this; TaskDispatcher.init(PerformanceApp.this); TaskDispatcher dispatcher = TaskDispatcher.createInstance(); dispatcher.addTask(new InitAMapTask()) .addTask(new InitStethoTask()) .addTask(new InitWeexTask()) .addTask(new InitBuglyTask()) .addTask(new InitFrescoTask()) .addTask(new InitJPushTask()) .addTask(new InitUmengTask()) .addTask(new GetDeviceIdTask()) .start(); dispatcher.await(); LaunchTimer.endRecord(); DexposedBridge.hookAllConstructors(ImageView.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { super.afterHookedMethod(param); DexposedBridge.findAndHookMethod(ImageView.class, "setImageBitmap", Bitmap.class, new ImageHook()); } }); // try { // DexposedBridge.findAndHookMethod(Class.forName("android.os.BinderProxy"), "transact", // int.class, Parcel.class, Parcel.class, int.class, new XC_MethodHook() { // @Override // protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // LogUtils.i( "BinderProxy beforeHookedMethod " + param.thisObjecObservablet.getClass().getSimpleName() // + "\n" + Log.getStackTraceString(new Throwable())); // super.beforeHookedMethod(param); // } // }); // } catch (ClassNotFoundException e) { // e.printStackTrace(); // } // BlockCanary.install(this, new AppBlockCanaryContext()).start(); initStrictMode(); // new ANRWatchDog().start(); }
Example #8
Source File: MMKVUtils.java From TemplateAppProject with Apache License 2.0 | 4 votes |
public static MMKV getsMMKV() { if (sMMKV == null) { sMMKV = MMKV.defaultMMKV(); } return sMMKV; }
Example #9
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()); }
Example #10
Source File: BenchmarkManager.java From FastSharedPreferences with Apache License 2.0 | 4 votes |
public void init(Context context) { this.context = context.getApplicationContext(); MMKV.initialize(this.context); }
Example #11
Source File: AppStartActivity.java From AndroidAnimationExercise with Apache License 2.0 | 4 votes |
@Override protected void onDestroy() { super.onDestroy(); MMKV.defaultMMKV().putBoolean("running", true); }
Example #12
Source File: MMKVUtils.java From TemplateAppProject with Apache License 2.0 | 2 votes |
/** * 初始化 * * @param context */ public static void init(Context context) { MMKV.initialize(context.getApplicationContext()); sMMKV = MMKV.defaultMMKV(); }