Visit GitHub RepoDatabase


A fast way to store POJO in sqlite on an Android device without troubling yourself with database creation.

Build Status Download


Google introduced Room which does the same thing, but better. I thereby deprecate Android-LazyDatabase, it's not useful anymore. It's still a good tutorial about how to upload artifacts to JCenter though.

What is it?

If you are working on a proof of concept app for Android (you should probably not use it for production in it's current state), and you need to store some good old POJO, this library is there for you. As the title says, it's a database for lazy people.

Warning Warning

Seriously, don't use it for production, only for proof of concept or stuff like that. I mean, really, I might break everything with the next release. It's far from being future proof yet.


For Maven


For Gradle

compile ''

How to?

Let's say you have a good old POJO class, like this:

public class GoodOldPojo {
  public String name;
  private int randomNumber;
  private float someValue;

  public GoodOldPojo(float someValue){
    this.someValue = someValue;

  public float getSomeValue() {
    return someValue;

First, modify it by setting a primary key, like that, and add an empty constructor:

import net.redwarp.library.database.annotation.PrimaryKey;

public class GoodOldPojo {
  public long key;
  public String name;
  private int randomNumber;
  private float someValue;

  public GoodOldPojo(){}


You will then have to create a DatabaseHelper object, using a Context, that you will use to save and retrieve all your objects.

import net.redwarp.library.database.DatabaseHelper;


GoodOldPojo pojo = new GoodOldPojo(0.45f);
DatabaseHelper helper = new DatabaseHelper(context);


Saving is then straightforward:;

It will create the database if it doesn't exist yet, and then save the object, and setting the long key to the inserted row value.

Saving in batch


Retrieving all data

List<GoodOldPojo> allPojos = helper.getAll(GoodOldPojo.class);

Retrieving one single POJO

GoodOldPojo retrievedPojo = helper.getWithId(GoodOldPojo.class, 2);

Object count

long count = helper.getCount(GoodOldPojo.class);

Chaining stuff

Let's say you have one POJO containing another POJO, like that:

public class GoodOldPojo {
  private OtherPojo object;

By default, it won't be saved. If you want it to be saved, you have to add the annotation @Chain to the field, like that:

public class GoodOldPojo {
  @Chain private OtherPojo otherPojo;

And voila, the otherPojo will be saved as well. By default, deleting the first one will also delete the second one. If you don't want the first item deletion to cascade on the second one, modify your class this way:

public class GoodOldPojo {
  @Chain(delete = false) private OtherPojo otherPojo;

What's left to do?

  • A shit load
  • Clear should also deleted chain elements
  • Relations of type one to many
  • Benchmarking (I mean, how fast is it compared to an hand written database)
  • Search
  • Unique keyword, etc...
  • Nothing, it's deprecated
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

Become Pro in Android by watching videos