Skip to content Skip to sidebar Skip to footer

Introduction Of Sharedpreference In Tap Counter App Causes App Crash

I'm trying to do a basic tap counter app that stores counter value to sharedpreference. App works as normal as a tap counter without sharedpreference when I run it, but when I intr

Solution 1:

TextView and int are not good friends so use:

tv_tapped.setText(String.valueOf(valueString)); // will convert the int to String
tv_tapped.setText(String.valueOf(counter));     // another case 

when you pass an int what Android does is , from void setText (int resid)

Sets the text to be displayed using a string resource identifier

so since there will be no resource match found because it's just a random number passed by you so hence exception

Post a Comment for "Introduction Of Sharedpreference In Tap Counter App Causes App Crash"