Skip to content

javycoder/JSave

Repository files navigation

JSave for Android

English

JSave是一款轻量级的键值对储存android工具库。

使用方法

在Android Studio中的build.gradle中加入:

dependencies {
compile 'javy.lib:JSave:1.0'
}

在您的Application调用

JSave.init(context);

储存

可以储存基本类型float,int,double,long等

boolean isSuccess=JSave.put("text","Hello world");//储存字符串
JSave.put("float",3.14f);//储存单精度浮点
JSave.put("double",3.1415);//储存双精度浮点
JSave.put("boolean",false);//储存布尔值

也可以储存JavaBen等一些简单的Object

public class TestBean {
    private float lon;
    private float lat;

    public float getLon() {
        return lon;
    }

    public void setLon(float lon) {
        this.lon = lon;
    }

    public float getLat() {
        return lat;
    }

    public void setLat(float lat) {
        this.lat = lat;
    }
}
TestBean tb=new TestBean();
tb.setLat(12.34567f);
tb.setLon(23.123456f);
JSave.put("object",tb);

读取

String text=JSave.get("text");//
boolean boo=JSave.get("boolean");
TestBean tb=JSave.get("object");

删除

//我要删除key为"text"的储存
JSave.put("text",null);
//或者这样写
Boolean isSuccess=JSave.delete("text");
//删除所有数据
int count=JSave.deleteAll();

修改

//修改“text”的值为"SB"
JSave.put("text","SB");

About

A lightweight key value storage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages