Skip to content

KObjectSave is developed to replace Android SharedPreferences, it supports int,string,Date,List and more(代替Android SharedPreferences的键值存储方式,支持几乎所有类型)

License

Notifications You must be signed in to change notification settings

gojuukaze/KObjectSave

Repository files navigation

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/

About

KObjectSave is developed to replace Android SharedPreferences, it supports int,string,Date,List and more(代替Android SharedPreferences的键值存储方式,支持几乎所有类型)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages