I came across some libraries that needs to be in Application
class.
Lets have a look at PrefCompat.
First we initialize it
public class Application extends android.app.Application {
@Override
public void onCreate() {
super.onCreate();
Pref.init(this);
}
}
and then we can use it anywhere like
Pref.putString("name", "Tushar");
Which is convenient, looks nice and advantage of that is you don't have to pass context again and again inside activities and fragments like
Pref.with(this).putString("name", "Tushar");
it makes the code look beautiful too (in my opinion).
So my question basically is:
Is there any side effects of initializing the library or any class like that?
any thoughts with some explanation will be really appreciated.
Thanks