I have some code that will store the number of times a particular OS has been voted for on Firebase. I use the following to store it:
DatabaseReference windowsChoice;
And inside the onCreate method:
FirebaseDatabase.getInstance().getReference("Windows");
Inside the button method I store the data to firebase with:
String id = "TimesClicked";
windowsChoice.child(id).setValue(b); //b holds the amount of times that Windows has been clicked
The resulting format is such:
{"Windows":{"TimesClicked":8},"choice1Num":23} // ignore choice1Num
The following code will get me the value of Windows (TimesClicked:8):
String result = new Connector().execute().get();
JSONObject ob = new JSONObject(result);
String jsonString = ob.getString("Windows");
String id = "TimesClicked";
windowsChoice.child(id).setValue(b);
intent.putExtra("result", jsonString);
startActivity(intent);
But how can I get the value of the TimesClicked label?