Skip to content Skip to sidebar Skip to footer

How To Override `tostring()` Properly To Get Rid Of Hash Code

I'm retrieving test data from Room, but all I get is the hash-code data, even though I override the toString() method in my @Entity class. How do I know if the override method is u

Solution 1:

You are calling toString() on ComputableLiveData, you have to call toString() on myEntities which will in turn call toString() on the individual elements which are MyEntity.

myViewModel.getAllData().observe( this, new Observer<List<MyEntity>>() {
    @Override
    public void onChanged(@Nullable List<MyEntity> myEntities) {
        Log.d("TAG: ", "DATA CHANGED! " + myEntities.toString());
    }
});

Post a Comment for "How To Override `tostring()` Properly To Get Rid Of Hash Code"