This is my first question here :)
This is my Firebase:
{
"Users": {
{
"G2u5-1yQI-GaKN" : {
"login" : "Tom",
"name" : "Tom",
"password" : "1234"
},
"JMtk-T2AZ-LJY8" : {
"login" : "Ann",
"name" : "Ann",
"password" : "abcd"
}
}
}
}
I want to get value of name key of JMtk-T2AZ-LJY8 user (Ann) and set it as text of TextView in my app widget.
My code is:
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.my_widget);
final DatabaseReference reference = FirebaseDatabase.getInstance().getReference().child("Users").child("JMtk-T2AZ-LJY8");
views.setTextViewText(R.id.textView2, String.valueOf(reference.child("name").getValue()));
I cannot use getValue() method here, i don't know why?
When I use similar code in onCreate method of MainActivity, it works fine (it returns "Ann:), but not in app widget. What is the solution?