I am following Single Activity-Multiple Fragments design pattern where navigation between fragments is done via Navigation Graph.
I need Shared Preference for the app.
However, where should I initialize it ?
Inside Activity or inside Fragment ?
In case, If I need to initialize inside fragments, then shall I do the initialization in onCreate()
callback of Fragment.
I studied all the Activity and Fragment Lifecycle before posting this question.
But I feel like initialize Shared Preference in Fragment then every time the fragment is destroyed/re-created the initialization will happen.
Hence need guidance to build a performant and robust solution.
Please advice.
question from:
https://stackoverflow.com/questions/65934440/where-to-initialize-shared-preferences-for-better-performance 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…