I have an array called subscribedTo for my node users. Now I want to add some push ID's to this array whenever a user subscribes.
But push ID are replaced instead of adding.
How can I add a push id to an array?
Scheme
"tester@gmail,com": { "email": "tester@gmail,com", "hasLoggedInWithPassword": true, "name": "tester", "subscribedTo": [ "-KFPi5GjCcGrF-oaHnjr" ], "timestampJoined": { "timestamp": 1459583857967 } }
CODE
public void onSubscribe(View v) { final Firebase firebaseRef = new Firebase(Constants.FIREBASE_URL); final HashMap<String, Object> userMap = new HashMap<String, Object>(); pushIDList.add(PROG_ID); userMap.put("/" + Constants.FIREBASE_LOCATION_USERS + "/" + mEncodedEmail + "/subscribedTo", pushIDList); firebaseRef.updateChildren(userMap, new Firebase.CompletionListener() { @Override public void onComplete(FirebaseError firebaseError, Firebase firebase) { Toast.makeText(ProgramDetail.this, "You are subscribed", Toast.LENGTH_SHORT).show(); } }); }
android arrays firebase firebase-database
user3467240
source share