I have an activity that I go back and forth in it. but I want this code to run once inside it even if I switch activity.
//get the Current user id(uid)
userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
Log.i("UID",userId);
orderDatabaseReference = FirebaseDatabase.getInstance().getReference("Orders").child(userId);
id = orderDatabaseReference.push().getKey();
I know the methods onStart, onResume ... but they are also the same