I cant find a way to read data from firebase databse in c# android application.
I want to read value from child data/test. Question appers to be very simple, couldnt find a aimple way which i would understand online
DATABASE picture:
data
Problem with reading screens
before
after
Working connection:
var options = new Firebase.FirebaseOptions.Builder()
.SetApplicationId("1:191485419818:android:c3bef44f30f167e537be53")
.SetApiKey("AIzaSyBwLcDZ3wGyzkwP6SobH8KDDsl5Vq227Vg")
.Build();
if (fireApp == null)
fireApp = FirebaseApp.InitializeApp(this, options);
auth = FirebaseAuth.GetInstance(fireApp);
string FirebaseURL = "https://plsbrothers-default-rtdb.firebaseio.com/";
FirebaseClient rootNode = new FirebaseClient(FirebaseURL);
dataNode = rootNode.Child("data");
userNode = rootNode.Child("users");
//Trying to access the saved data and display it. Dont know it it is an issue with converting data to string and displaying it or i dont even access it properly (it shows Firebase.Database.Query.childQuery and not the data i want to display)
string testDisplay = dataNode.Child("test").ToString();
TextView currentCharacterName = FindViewById<TextView>(Resource.Id.test);
currentCharacterName.Text = testDisplay;
XML CODE:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="save"
android:textSize="25dp"
android:textColor="#000"
android:id="@+id/Btn"
android:layout_marginTop="280dp"
/>
<TextView
android:text="starting value"
android:textSize="30dp"
android:textColor="#000"
android:layout_marginTop="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/test" />
2
Answers
Connection:
Data Class, in these example it will be GalleryModel
Generete new file(optionally) for Tasks. In these case file name is GalleryRepo
Create new xml file.
Than in xml cs file
//Please add the Invalidate() method.