Firebaseui-android: Delete Item in ListView (Android)

Created on 7 Jun 2016  路  6Comments  路  Source: firebase/FirebaseUI-Android

How to Delete a Item on long press in ListView With the Update Firebase Code.
Can please Provide me the logic or Sample Code

Most helpful comment

You'll need to figure out the position that the user clicked on (which is unrelated to FirebaseUI). Once you know the position, you can call adapter.getRef(position).removeValue() to remove the item. The adapter will automatically update after that.

See this question on Stack Overflow: http://stackoverflow.com/questions/32997219/how-to-get-obj-key-from-firebaselistadapter-on-item-click-firebaseui or http://stackoverflow.com/questions/34028599/firebase-android-studio-remove-item-from-firebaselistadapter

All 6 comments

@dharan1011 this would not be a FirebaseUI feature. You can implement an OnLongClickListener however you want and then make the delete call to Firebase in the listener.

You'll need to figure out the position that the user clicked on (which is unrelated to FirebaseUI). Once you know the position, you can call adapter.getRef(position).removeValue() to remove the item. The adapter will automatically update after that.

See this question on Stack Overflow: http://stackoverflow.com/questions/32997219/how-to-get-obj-key-from-firebaselistadapter-on-item-click-firebaseui or http://stackoverflow.com/questions/34028599/firebase-android-studio-remove-item-from-firebaselistadapter

Thank You@puf You Just Solved my Major Issue. I new to the Firebase And Android . Anyway Thank You @puf

If I remove two items very fast, I got the exception "java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2"

@rodgarcialima Can you open a new issue for this with the code of how you delete the items? It would also be useful to see the full stack trace.

@puf It was my mistake. I used position instead of viewHolder.getAdapterPosition()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

avyx7 picture avyx7  路  3Comments

iChintanSoni picture iChintanSoni  路  4Comments

akrmn picture akrmn  路  4Comments

ghost picture ghost  路  5Comments

judeebene picture judeebene  路  4Comments