How to get obj key from FirebaseListAdapter on Item Click. FirebaseUI

How to get obj key from FirebaseListAdapter on Item Click. FirebaseUI

When subclassing FirebaseListAdapter in FirebaseUI how can one get the obj key of the item clicked?
FirebaseListAdapter has the following method which gets itemId, but returns long. But I require the object key which is in the default string format.
public long getItemId(int i) {
    return (long)this.mSnapshots.getItem(i).getKey().hashCode();
}

Solutions/Answers:

Solution 1:

The FirebaseListAdapter assumes that you always know the index/position of the item you are interacting with. Given the Android context this makes sense, since collection views are index based.

Once you know the position, you can call adapter.getRef(position) to get the Firebase reference to the object. On that reference, you can call getKey() to get the key. Although I recommend only doing that as a last resort.

References

Related:  Firebase console is not loading