how do i update my listView after deleting the data in firebase realtime database
Date : March 29 2020, 07:55 AM
should help you out After call of for loop of appleSnapshot.getRef().removeValue(); then remove that position item from arraylist , then call notifydatasetchanged and check like below public void deleteTask(View view) {
int index=listView.getPositionForView(view);
String str= (String) arrayAdapter.getItem(index++);
DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
Query taskQuery = ref.child("Todo").orderByChild("Task").equalTo(str);
taskQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot appleSnapshot: dataSnapshot.getChildren()) {
appleSnapshot.getRef().removeValue();
}
arrayList.remove(listView.getPositionForView(view)); // remove the item from list
arrayAdapter.notifyDataSetChanged();// notify the changed
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("TAG", "onCancelled", databaseError.toException());
}
});
}
|
Getting Data from Firebase realtime database, Android Studio, Java
Tag : java , By : omaidog
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I am looking for a way to get data from the firebase real-time database in a format like an array[] or a String. , To get the a list of uids, please use the following code: DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference usersRef = rootRef.child("Users");
ValueEventListener valueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
List<String> list = new ArrayList<>();
for(DataSnapshot ds : dataSnapshot.getChildren()) {
String uid = ds.getKey();
list.add(uid);
}
//Do what you need to do with your list
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d(TAG, databaseError.getMessage()); //Don't ignore errors!
}
};
usersRef.addListenerForSingleValueEvent(valueEventListener);
|
Unable to update Firebase Realtime Database in Android
Tag : java , By : PaulPlum
Date : March 29 2020, 07:55 AM
I wish this helpful for you Some changes I can suggest which will make your code more clear and easy to debug. First use names for your database references which identify node in database so: FirebaseDatabase db = FirebaseDatabase.getInstance();
DatabaseReference userProfileRef = db.getReference("users").child(userId);
map.add("email",email)
map.add("name",name);
userProfileRef.update(map);
|
How to retrieve array data from children node in Firebase Realtime Database Java? (Firebase Recycler Adapter)
Tag : java , By : scotta01
Date : March 29 2020, 07:55 AM
it helps some times The problem in your code is that your url_photo_collage field is declared in your DolanItemClass class of type String while in your database is an array. To solve this, change the type of your field from String to a List and get it accordingly in your adapter.
|
Get realtime data change update when data changes on Firebase Realtime Database
Date : March 29 2020, 07:55 AM
hope this fix your issue If you need to get data in real-time, you should use a real-time listener. To solve this, please change your code to: FirebaseDB.batch.child(batch).addValueValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
//Update recyclerview here
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
|