-3

I have a problem with my counter. I'v used this as my template: Continuing integer counter from sharedpreferences

But if I stop the app and reopen it and tap one button the Counter goes to 0. But if I only go home and reopen the app the counter goes higher. How can I fix this?

counter = Integer.ParseInt(userString); //this line.

Doesn't work for me. Please help me.

Community
  • 1
  • 1
log
  • 1
  • 2
  • I am not sure what you are trying to achieve here. Please elaborate your goals. Also the integer counter is not initialized. You need to give it a value and then make sure it gets re-initialized by overriding the onPause and onRestart methods. – Sanved Apr 24 '16 at 14:57
  • @SanVed I like something like Cookie Clicker. How can I do this that after I restart the App to start from the number before i closed the app. Sorry for my bad englisch. – log Apr 24 '16 at 15:00
  • ???????????? @SanVed – log Apr 24 '16 at 16:13
  • So you want a counter. You basically open the app and then click to increase the count and then you want the value to be stored right ? – Sanved Apr 24 '16 at 17:09

1 Answers1

0

now I have it done. It Works. I've used:

counter = Integer.parseInt(String.valueOf(userString));

Thanks for @SanVed to answer me.

log
  • 1
  • 2