GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - liuhao722/MeKV: Android Key-Value 管理框架

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

33 Commits
33 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
app
app
 
 
art
art
 
 
gradle/wrapper
gradle/wrapper
 
 
mekv-annotations
mekv-annotations
 
 
mekv-processor
mekv-processor
 
 
mekv
mekv
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

MeKV

MeKV 是 Android Key-Value 管理框架,为了解决 Android 平台下各种繁琐的配置类代码

使用了 https://github.com/Tencent/MMKV 来存储数据,支持自定义存储数据

特点

  • 不用写 get/set
  • 自动生成代码
  • 可以自定义后缀

配置

dependencies {
    implementation 'vip.ruoyun.mekv:mekv-core:1.0.1'
    annotationProcessor 'vip.ruoyun.mekv:mekv-compiler:1.0.1'
}

使用

初始化

MeKV.init(new MMKVStrategy(this));

两种模式

  • model 模式
  • key-value 模式

model 模式

支持的类型

  • Parcelable
@MeKV(model = true) //model 默认为 true
public class User implements Parcelable {
    private String name;

    public String getName() {
        return name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    //...Parcelable code
}

生成的代码

-w1093

使用

User user = UserMeKV.getUser();//获取
if (user != null) {
    user.setName("");
    user.getName();
}
UserMeKV.saveUser(user);//保存
UserMeKV.remove();//清除

key-value 模式

支持的类型

  • String
  • float
  • boolean
  • double
  • long
  • int
  • byte[]
  • Set<String>
  • Parcelable
  • 不支持包装类型

设置 @MeKV(model = false) ,model 为 false

@MeKV(model = false)
public class People {
    //不需要 get/set 方法

    @Ignore//不会自动生成属性代码
    private String name;

    private boolean isOld;

    private int age;

    private double doubleMoney;

    private long longMoney;

    private byte[] mBytes;

    private User user;//对象 必须 implements Parcelable

    private Set<String> setString;
}

使用

PeopleMeKV.saveName("value");//保存
PeopleMeKV.getName();//获取
PeopleMeKV.removeName();//删除对应的字段信息

生成的代码

-w1093

清除所有记录

MeKV.clear();//清除所有记录

自定义 key

默认为包名+生成的类名。

@MeKV(key = "CustomKeyUserKey")
public class User implements Parcelable {
    ...
}

自定义后缀

默认为 MeKV 后缀。

@MeKV(suffix = "Manger")
public class People {
....
}
//生成类
PeopleManager

高级玩法

自定义 MMKV https://github.com/Tencent/MMKV/wiki/android_advance_cn

MMKV mmkv = MMKV.defaultMMKV();
...code//MMKV高级特性
MeKV.init(new MMKVStrategy(mmkv));

去除不需要的 so 文件

MMKV 默认提供各种版本的 so文件,可以进行配置

-w1093

android {
    compileSdkVersion 29
    minSdkVersion 16 //MMKV 要求最低版本
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
}

混淆相关

内置混淆,不需要任何配置.

About

Android Key-Value 管理框架

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.