Resources$NotFoundException -- Weather app

-3

Error while installing the app.

Error--"android.content.res.Resources$NotFoundException: Resource ID

0xffffffff"

Please help..

int viewType = getItemViewType(cursor.getPosition());
        switch (viewType) {
            case VIEW_TYPE_TODAY: {
                // Get weather icon
                viewHolder.iconView.setImageResource(Utility.getArtResourceForWeatherCondition(
                        cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID)));
                break;
            }
            case VIEW_TYPE_FUTURE_DAY: {
                // Get weather icon
                viewHolder.iconView.setImageResource(Utility.getIconResourceForWeatherCondition    (
                        cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID)));
                break;
            }
}
android
asked on Stack Overflow Jul 23, 2018 by Ankit • edited Jul 24, 2018 by Joshua

1 Answer

-2

You are trying to give -1 in getString() function or while accessing some resource

EDIT: After reviewing your github code, I got the reason of crash that

Utility.getIconResourceForWeatherCondition(cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID)) 

this Utility method, returns -1 in a case where

cursor.getInt(ForecastFragment.COL_WEATHER_CONDITION_ID)

this returns, 904 and 904 is not listed in any if-else conditions of Utility function, hence the last return statement returns -1. I guess, either there is an unintended entry in database or some conditions are missing in Utility function, or there is a third option that you return some default drawable instead of -1 from the last return statement.

Hope it solves your problem.

answered on Stack Overflow Jul 23, 2018 by parekhkruti26 • edited Jul 24, 2018 by parekhkruti26

User contributions licensed under CC BY-SA 3.0