pilgr / Paper

Paper is a fast NoSQL-like storage for Java/Kotlin objects on Android with automatic schema migration support.
Apache License 2.0
2.34k stars 234 forks source link

Paper.init() inside custom view #173

Closed developerGM closed 4 years ago

developerGM commented 4 years ago

I am trying to add Paper inside a custom view

@Override protected void onFinishInflate() { super.onFinishInflate(); Paper.init(mContext); }

but I have a render exception

java.lang.RuntimeException: Couldn't create Paper dir: null\io.paperdb

pilgr commented 4 years ago

Hey, init Paper in custom view is a bad idea. Init should be called once, preferably when application or activity is created. Please refer to the doc https://github.com/pilgr/Paper#initialize-paper