RT DB Storing object

Advertisements
        //Getting instance
        FirebaseFirestore db = FirebaseFirestore.getInstance();

        //Creating and initializing User object
        User user = new User("user1234","waqas","younis","first","january","1990");

        //Getting Reference to "users" collection
        CollectionReference collectionReference = db.collection("users");

        //Getting reference to "new doc" document
        DocumentReference documentReference = collectionReference.document("new doc");

        //Writing data
        documentReference.set(user);