I am a beginner to android programming, learning on my own. I am using android studio 4.1.1' and kotlin`.
I followed a tutorial to create a Firebase login setup.
... in part...
private var mAuth: FirebaseAuth? = null
...
// in override fun onCreate()
mAuth = FirebaseAuth.getInstance()
// once a user is logged in, I can do:
val userID = mAuth!!.currentUser!!.uid
The tutorial (and other tutorials and threads) did not cover whether the mAuth!!.currentUser!!.uid persists across multiple Activities or Fragments. Is this possible? How do I check for the currentUser on any given .kt file?
I could create a Global class with a companion object{} and set Global.userID = "test" then once I a user is logged in, I could set Global.userID = mAuth!!.currentUser!!.uid, but that doesn't seem like the best option.
Thanks for any advice or pointers.