Answer the question
In order to leave comments, you need to log in
FirebaseDatabase error: failed to convert Hashmap to String in Android app, how to fix?
Can't get child value via ValueEventListener.
Error:
My FirebaseDatabase:
Code:
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
DatabaseReference ref = databaseReference.child(path);
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String value = dataSnapshot.getValue(String.class);
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
clipboard.setText(value);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
String value = dataSnapshot.getValue(String.class);
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference();
DatabaseReference ref = databaseReference.child(path);
ClipboardManager clipboard = (ClipboardManager) getApplicationContext().getSystemService(CLIPBOARD_SERVICE);
String data = clipboard.getText().toString();
ref.setValue(data);
everything is in order, although the DatabaseReference are the same. I can not understand what the problem is, I will be grateful for the help.
Answer the question
In order to leave comments, you need to log in
data is not a string, but a hashmap, as they write to you in the logs.
I have one word for you: debugger.
and soon a lot will become clear!
Firebase returns hashmap with one line
Key: uzmtn
Value: data
If you need a line at once, then it's like this:
DatabaseReference ref = databaseReference.child(path).child("uzmtn");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question