/LeftDB-android

LeftDB - fork of the RightUtils database utils

Primary LanguageJavaOtherNOASSERTION

LeftDB-android

Is a simple SQLite ORM for Android. Fork of the RightUtils database utils.

Download

Gradle dependency:

repositories {
  jcenter()
}
    
dependencies {
  compile 'com.github.andreyrage:leftdb:1.7'
}

How it work

To work with the database you just need to use a helper. LeftDB can save and restore objects from database. See Getting started for details.

DbHelper dbHelper = DbHelper.getInstance(this);

SimpleEntity simpleEntity = new SimpleEntity();

dbHelper.add(simpleEntity); //save in the database

List<SimpleEntity> entities 
    = dbHelper.getAll(SimpleEntity.class); //get all SimpleEntity objects from database
  
dbHelper.delete(simpleEntity); //delete object from database

To execute in not UI thread you can use AsyncCall:

AsyncCall.make(new AsyncCall.Call<List<SimpleEntity>>() {
    @Override
    public List<SimpleEntity> call() {
        return dbHelper.getAll(SimpleEntity.class)
    }
}, new AsyncCall.Do<List<SimpleEntity>>() {
    @Override
    public void doNext(List<SimpleEntity> simpleEntities) {
        // returned result to UI thread
    }
}).call();

For more information, see example or documentation.