TinyDB--Android-Shared-Preferences-Turbo icon indicating copy to clipboard operation
TinyDB--Android-Shared-Preferences-Turbo copied to clipboard

java.lang.NullPointerException: listFood.get(0) must not be null

Open betodev98 opened this issue 2 years ago • 1 comments

fun insertFood(item: FoodDomain){

    listFood = tinyDB.getListObject("CartList")
    listFood.add(item)
    tinyDB.putListObject("CartList",listFood)
    var fod : FoodDomain = listFood.get(0)
    }

The error is: when i get the list, it have size, 1 or 2 or 3 , is normal; but if i want get one object of the list, it say "must not be null"

like IS A LIST WITH SIZE BUT ALL OBJECT ARE NULL OR NOT EXIST ? please help :c i have this problem 2 months

betodev98 avatar Dec 04 '22 09:12 betodev98

Hello, can you share the error log for the crash? it will help me find out what the problem is and how to solve it.

kcochibili avatar Dec 06 '22 02:12 kcochibili