Saxi
Saxi

Reputation: 3

Save Current Time And Date To Firebase Database

I have Add a button to my app . When i click the button the current time save to Sp. But i want to save this to my firebase database. How can i do this?

private void saveButtonClickTime() {
        sp1.edit().putLong("mTime1", System.currentTimeMillis()).apply();
    }

Upvotes: 0

Views: 1804

Answers (1)

Muntasir Aonik
Muntasir Aonik

Reputation: 1957

Try This One. It will work .

 private void saveButtonClickTime() {
            sp1.edit().putLong("mTime1", System.currentTimeMillis()).apply();
            DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
            rootRef.child("time").setValue(sp1);
    }

Upvotes: 1

Related Questions