android - SQLite initialization on Fragment -
I just read because of getting a reference to initialize a database. The answer to the 2 most votes where to get the piece # getActivity ()
to get the reference
or piece # onAttach (activity)
Callback method is doing inside.
This is to maintain a well-documented code, I want to avoid working in the "alternative" way, but the way it should have been done.
There is life-cycle found here: onAttach ()
looks like onCreate
, which means getActivity ()
At this point empty should not be
questions will be:
- This means that
onAttach Is to start a database inside ()
? - It is possible to go back to
null
for getActivity () when call is made insideonCreate ()
Only theonAttach ()
has already been called?
It looks like you want to make better setup at the right time. Easily allow DB to reach from anywhere through the resolver.
Comments
Post a Comment