Create Note With Userid Firebase Android Studio
Hello guys in this application i use firebase as backend where i have created users with firebase auth. i want to Add the firebase Auth id in the note so i can retrive notes to tha
Solution 1:
Your current code pushes new ToDoList
objects to /toDo
.
So you can link a user to that ToDoList
before using it with setValue
using something similar to:
ToDoListtoDo=newToDoList (notes,prio); // object of class ToDoList in models
toDo.setUserId(firebaseAuth.getCurrentUser().getUid())
databaseReference.push().setValue(toDo)
Alternatively, you can nest the ToDoList
objects under the user ID using:
ToDoListtoDo=newToDoList (notes,prio); // object of class ToDoList in models
databaseReference.child(firebaseAuth.getCurrentUser().getUid()).push().setValue(toDo)
Note: Don't forget to handle cases where your active user is not logged in.
Post a Comment for "Create Note With Userid Firebase Android Studio"