package io.paperdb;

import android.content.Context;

public class Paper {
    static final String TAG = "paperdb";

    private static final String DEFAULT_DB_NAME = "paperdb";

    private static Paper INSTANCE;

    private final Storage mStorage;

    public static void init(Context context) {
        INSTANCE = new Paper(context);
    }

    public static void destroy(Context context) {
        new Paper(context).mStorage.destroy();
    }

    public static <T> void put(String key, T value) {
        if (value == null) {
            INSTANCE.mStorage.deleteIfExists(key);
            return;
        }
        INSTANCE.mStorage.insert(key, value);
    }

    public static <T> T get(String key) {
        return get(key, null);
    }

    public static <T> T get(String key, T defaultValue) {
        T value = INSTANCE.mStorage.select(key);
        return value == null ? defaultValue : value;
    }

    public static boolean exist(String tableName) {
        return INSTANCE.mStorage.exist(tableName);
    }

    public static void delete(String tableName) {
        INSTANCE.mStorage.deleteIfExists(tableName);
    }

    private Paper(Context context) {
        this(context, DEFAULT_DB_NAME);
    }

    private Paper(Context context, String dbName) {
        mStorage = new DbStoragePlainFile(context.getApplicationContext(), dbName);
    }

}

@@ -157,24 +157,27 @@
 _DB_NAME = %22
+io.
 paperdb%22;%0A%0A 
@@ -266,20 +266,21 @@
  static 
-void
+Paper
  init(Co
@@ -296,32 +296,39 @@
 text) %7B%0A        
+return 
 INSTANCE = new P
@@ -384,72 +384,72 @@
 roy(
-Context context) %7B%0A        new Paper(context).mStorage.destroy()
+) %7B%0A        INSTANCE.mStorage.destroy();%0A        INSTANCE = null
 ;%0A  
@@ -475,20 +475,21 @@
 tic %3CT%3E 
-void
+Paper
  put(Str
@@ -600,38 +600,29 @@
     
-    return;
+%7D else %7B
 %0A     
-   %7D%0A
        
- 
 INST
@@ -651,24 +651,59 @@
 ey, value);%0A
+        %7D%0A        return INSTANCE;%0A
     %7D%0A%0A    p
@@ -1072,20 +1072,21 @@
  static 
-void
+Paper
  delete(
@@ -1150,32 +1150,57 @@
 sts(tableName);%0A
+        return INSTANCE;%0A
     %7D%0A%0A    priva

Migrate to Paper library