Sweet-Mother-of-SQLite
jianastrero
11
Visit GitHub RepoDatabase

Sweet-Mother-of-SQLite

The Sweetest way into saving and loading sqlite

API

##Installation Add the JitPack repository to your build file then add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    compile 'com.github.jianastrero:Sweet-Mother-of-SQLite:v1.0'
}

##Usage - Instruction

###Instructions Call SweetSQLiteConfig.init atleast once in your application

SweetSQLiteConfig.init(this, "sweetmotherofsqliteexample");; //the first parameter is the context and the second is the database name

Extend SweetSQLite then call the super constructor and set the subclass instance always to this. then declare public fields. if wanted, you could add setters and getters.

public class SQLiteClass extends SweetSQLite {

    public String string;

    public SQLiteClass() {
        super();

        setSubclassInstance(this);
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }
}

####Saving: create an instance of your subclass then call save to save all data into the sqlite database

SQLiteClass sqLiteClass=new SQLiteClass();
sqLiteClass.setString("Count: "+ctr);
sqLiteClass.save();

####Loading: create an instance of your subclass then call load. there are two ways to load, by id or by whereClause. #####by id:

SQLiteClass sqLiteClass=new SQLiteClass();
sqLiteClass.load(ctr);

#####by whereClause:

SQLiteClass sqLiteClass=new SQLiteClass();
sqLiteClass.load("ID = "+ctr);

##Thats it! Now you can easily save and load to your sqlite database with a short and elegant code :)

Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer
Microsoft

Become Pro in Android by watching videos

OUR LEARNERS WORK AT