Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions paperdb/src/main/java/io/paperdb/Paper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ public static void init(@NonNull Context context) {
mContext = context.getApplicationContext();
}

/**
* Alternative to {@link #init(Context)} when {@link #book()} method is not needed.
*
* <p><b><font color="red">
* Do not use this constructor unless you are explicitely specifying location by using {@link #bookOn(String)}
* or {@link #bookOn(String, String)}.
* </font>
*/
public static void init() {
}

/**
* Returns book instance with the given name
*
Expand Down Expand Up @@ -94,8 +105,9 @@ public static void init(@NonNull Context context) {
}

private static Book getBook(String location, String name) {
if (mContext == null) {
throw new PaperDbException("Paper.init is not called");
if (location == null && mContext == null) {
throw new PaperDbException("Paper.init(Context) is not called. If you are calling Paper.init(), " +
"please call Paper.init(Context) instead.");
}
String key = (location == null ? "" : location) + name;
synchronized (mBookMap) {
Expand Down