I am new to firebase and am trying to use this as a backend for an Android app to store data. The data format is a key, a pair of values.
This is the code I use to store data:
Map<Integer, PersonData> map = new HashMap<Integer, PersonData>(); map.put(PersonData.getID(), new PersonData("abcd", 12345)); Firebase ref = new Firebase(url).push(); ref.setValue(map);
Due to the click link used, data is saved as follows:
-J5upSABqTLJ1Wfu-jFq 12345 id: 12345 name: abcd
Where - how do I want the data to be stored as follows:
12345 id: 12345 name: abcd
I'm not quite sure that the code example above is the right way to store data. Because I want to be able to update existing data at a later point in time. Any suggestions?
EDIT 1: I think I need to use push so that I don't overwrite existing data in the firebase repository. I just tried to return the data using the getValue () method, and I can only retrieve the data that is in the MAP
EDIT 2: without using the push () method with my link, I see that any previous data is overwritten and only the latest information is available. I wonder if they are the best way to get the link and still retain the previous information.
android firebase
bhavs
source share