Save class to firebase

Viewed 5822

My class is CredicardinfoObject.class

public class CreditcardinfoOjbect implements Serializable {
    private static final long serialVersionUID = 1L;

    public static String title;
    public static String startTime;
    public static String endTime;
    public static String day;

}

This class has only static proprieties. There is no instantiation needed.

In my mainActivity.class, I want to set the values of the class and then store this firebase database. This is my mainActivity.class.

    CreditcardinfoOjbect.title = "foo";
    CreditcardinfoOjbect.startTime = "bar";
    CreditcardinfoOjbect.day = "1";
    CreditcardinfoOjbect.endTime = "2";

    final FirebaseDatabase database = FirebaseDatabase.getInstance();
    String uid = "";
    FirebaseAuth auth = FirebaseAuth.getInstance();
    FirebaseUser user = auth.getCurrentUser();
    if (user != null) {
        uid = user.getUid();
    }
    DatabaseReference ref = database.getReference("users").child(uid).child("account").child("creditcards");

    HashMap<String, Class<CreditcardinfoOjbect>> hashMap = new HashMap<>();
    hashMap.put("card", CreditcardinfoOjbect.class);
    ref.setValue("card",hashMap );

Unfortunatelly, this is not working. How can I store a the current value of a class in Firebase?

2 Answers
Related