Paper DB Android

Paper is an object-oriented storage option for android for java/kotlin.
it is a no-SQL database and supported by java and kotlin.
Papers provide a simple, fast, object container options in android.

Three most important features of Papers
  1. It can be used without any annotations, factory method, and class extension.  
  2. Adding and removing field to data class is not the developer's headache, it will handle automatically.
  3. Automatic schema migration support
Paper is a combination of the key/value data model and the object-oriented data model.
the paper used custom string as key and object as value.

Storing data in DB step by step-

Download Project source code from here

  1- add the dependency in Gradle

implementation 'io.paperdb:paperdb:2.7.1'

2- initialize Paper in Application class

public class ApplicationClass extends Application {
public void onCreate() {


3- Threading
    Paper.init() must be called in UI Thread;
    And other function, read, write, delete are thread-safe and must be called outside of the UI Thread.

4- Save data
Student student;
student = new Student("javaoneworld",

5- Read data

List<Student> studentList1;
studentList1 = new ArrayList<>();
studentList1 ="student");

6- use the default value if the object does not exist in the storage

List<Student> ="student"
                               new ArrayList<>());

7- Delete data for one key"student");

8- Removing all key for the given book;

9- Want to use the custom book"student1").write("student",student);"student2").write("student",student);"student3").write("student",student);"student4").write("student",student);

10- Return all key for an object in the book

List<String> allKeys =;

11- if you Want to Ignore some field from the saving process
     Use transient keyword with the field which you do not want to save

public transient String nikName = "Thor";
// nikName Won't be saved
12- if you want to change in your data model class, no worry, do changes what you want and it will manage automatically.
You can add and remove fields from the class.
  • The removed field will be ignored.
  • Newly added fields will have their default value.
Note- if you are changing only data type, it will not support.
example- in the start you have saved this model
class Student {
    public String name;
    public String email;
but after that, you want to change, see here

class Student {
    public String name;
    // public String email; removed field
    public Location location; // New field

the new field will initialize as the default value of null

13- Set Custom location for your file
 By default, Paper stored file path belongs to your apps package name


To set it on your SD card, 


//to create a custom book.

14- get the path;

That's all about .
thank for being here.
#stayhappy #staycode


  1. Very nice...Keep it up to spread knowledge..👍

    1. i'm trying my best, to reach tech world by spreading my knowladge.

  2. How to check if Object is not in it?