10月20日,北京【人工智能】源创会火热报名中,点击报名收获 AI 训练指南
Watch Star Fork

五十风 / KObjectSaveAndroidApache-2.0

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
KObjectSave is developed to replace SharedPreferences, it supports int,string,Date,List and more(代替SharedPreferences的键值存储方式,支持多种类型)
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md 1.74 KB

KObjectSave

KObjectSave is developed to replace android SharedPreferences, it supports int,string,Date,List and more
代替android SharedPreferences的键值存储方式,支持多种类型
中文README

Get started

Just add dependency (KObjectSave is available in jcenter):

dependencies {
    compile 'cn.ikaze.KObjectSave:library:1.0.0'
}

Usage

public class Student {
    int no = 1; //default 1
    String name = "gojuukaze";//default gojuukaze
    Date birthday = new Date(); //default now
    List<String> subjects;
    
    public String toString() {
        Format format = new SimpleDateFormat("yyyy-MM-dd");
        String birthdayString = format.format(birthday);
        return "No." + no + ", name: " + name + ", birthday: " + birthdayString + ", subjects: " + subjects;
    }
}

use KObjectSave to save Student

KObjectSave kSave = new KObjectSave(this, Student.class);
Student st = (Student) kSave.getObj();

st.no=23;
st.name="A";
st.subjects=new ArrayList<String>(){{add("math");add("physics");}};

try {
  kSave.save(st);
} catch (IOException | IllegalAccessException e) {
  e.printStackTrace();
}

load data

Student tempSt = (Student) new KObjectSave(this, Student.class).getObj();
lod.d("KObjectSave",""+tempSt);

Example

Example

Where published?

Here

NOTICE !!

  • KObjectSave dose not encrypt data, do not used to save password*

License

                            Apache License
                       Version 2.0, January 2004
                    http://www.apache.org/licenses/

Comments ( 0 )

You need to Sign in for post a comment

Help Search