Git Product home page Git Product logo

mmkvsharedpreferences's Introduction

mmkvsharedpreferences's People

Contributors

caij avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

13120241790

mmkvsharedpreferences's Issues

getAll()

Map<String, ?> all = preferences.getAll();
拿到的 value 是 ?,如果在外面想使用如何去遍历和拿到正确的类型?

            Set<String> keySet = preferences.getAll().keySet();
            for (String key : keySet) {

// if {
// }
}
Map<String, ?> all = preferences.getAll();
for (int i = 0; i < all.size(); i++) {
// if () {
// }
}

这个地方可能有点小问题

一般在页面上散着用是没有问题的,但是有时候想去集中管理去简化用法的时候就会产生问题详情如下:

例如下面代码我基于您的代码做了一个 KeyValueManager 的全局单例包装,put 的时候不需要再去 commit 或者 apply 。这时候全局只有一个 Editor

public void init(Context context, String sharedPreferencesName) {
    mContext = context;
    mPreferences = new MMKVSharedPreferencesFactory().getSharedPreferences(context, sharedPreferencesName, Context.MODE_PRIVATE);
    mEditor = mPreferences.edit();
}

这时候 MMKVEdit 内的 keyValues 缓存就会越来越大,而且我每次去 commit 的时候 commitUpdate 方法就会遍历,即使我只去 commit 一个简单的 int 值。咱们的库的设计在集中管理使用的情况下也会去遍历所有的 keyValues 重新去操作 mmkv 的接口。不知道大佬有没有考虑过这个场景?有什么好的解决办法和意见吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.