This is my JSON from firebase database:
{
"57c80ec0-e73f-49df-8296-25999e194288" : {
"email" : "ss@zz.mm",
"hotel" : {
"-KEaYE1YfvPTRfgcO6Z_" : {
"latit" : 20.15135303358223,
"longit" : 23.86566750705242,
"name" : "Westin",
"rating" : 1,
"review" : "hehehe hehehe hehehe hehehe hehehe hehehe hehehe"
},
"-KEaYGDhbFAN99GyY0cH" : {
"latit" : 30.211601559876424,
"longit" : -4.754576571285725,
"name" : "Sheraton",
"rating" : 5,
"review" : "hohoho hohoho hohoho hohoho hohoho hohoho hohoho hohoho hohoho hohoho"
},
"-KEbjCjmx4-Xmr_1aVCy" : {
"latit" : 20.58906906737089,
"longit" : 25.271570831537247,
"name" : "Admiral",
"rating" : 3,
"review" : "hahaha hahaha hahaha hahaha hahaha hahaha hahaha hahaha hahaha hahaha hahaha hahaha"
}
},
"password" : "nn",
"username" : "ss"
},
"c01528ea-a22c-43de-b77a-bc833c5e394c" : {
"email" : "ses@ses.ses",
"hotel" : {
"-KEaLImMODDRiDwK3gSo" : {
"latit" : 18.160196227874213,
"longit" : 26.094263345003128,
"name" : "Osijek",
"rating" : 2,
"review" : "lalala lalala lalala lalala lalala alalal lalala lalala lalala lalalal"
},
"-KEaLKSEg1psa4xvggse" : {
"latit" : 31.71881281252363,
"longit" : -2.9933271557092667,
"name" : "Slavonija",
"rating" : 4,
"review" : "aaaa aaaa aaaa aaaa aaaa aaaaa aaaaa aaaa aaaa aaaaa aaaa aaaaaa aaaaa aa"
}
},
"password" : "ses",
"username" : "ses"
}
}
@Override
public Map<String, Object> rateHotel(String name, double lat, double lon) {
Map<String, Object> hotel = new HashMap<>();
hotel.put("name", name);
hotel.put("latit", lat);
hotel.put("longit", lon);
return hotel;
}
@Override
public void addHotel(String name, double lat, double lon) {
String uid = firebase.getAuth().getUid();
final Firebase hotelsRef = new Firebase("https://josip-my-application.firebaseio.com/Users/" + uid + "/hotel/");
hotelsRef.push().setValue(rateHotel(name, lat, lon));
presenter.onSuccess(name, lat, lon);
}
This is how I pushed my hotels in a database. I log in and I have logged in user's list of hotels. when I click on one hotel from the list, I'm new activity where I want to edit some fields from that certain hotel.
How am I supposed to look for, or what firebase URL should I use to reach to a certain hotel key?
This is what url I've been using for pushing new hotel into firebase...it puts new hotel in "hotel" field and generates key for every new hotel. How can I get that key?
Firebase userRef = new Firebase("https://josip-my-application.firebaseio.com/Users/");
String uid = stringObjectMap.get("uid").toString();
userRef = new Firebase("https://josip-my-application.firebaseio.com/Users/" + uid + "/hotel/);