I had the same problem when developing an application. If the user had his phone on the plane or was disconnected at the first start, they may have reached the point where they needed to save the data before successful anonymous authentication.
" " , , . , , , . , , Firebase , .
, push , . SharedPreferences .
db = FirebaseDatabase.getInstance();
db.setPersistenceEnabled(true);
dbRef = db.getReference();
String key = dbRef.child("unauthenticated").push().getKey();
dbRef.child("unauthenticated").child(key)
.child("somedata").setValue("testing");
, , , . ...
dbRef.child("unauthenticated").child(key).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.d("DB", "Got value from database: " + dataSnapshot.child("somedata").getValue());
if(FirebaseAuth.getInstance().getCurrentUser() != null) {
}
}
@Override public void onCancelled(DatabaseError databaseError) {}
});