0

My app only contains Images where each level contains different pictures and I am having problem trying to save the data of my app. I mean, for instance, each time I reach a level(Lets supposed 7) in my app and when I closed my app all the data are lost due to the fact when I open it brings me back to the beginning(Level1.)

So I am wondering which method will be useful to store my data so that after I return in my app it brings me back where I left.

My app is done and I really need your HELP PLEASE because this is the last step that retains me to publish it.

Also, I intended to use SharePreferences it is documentation said it can only be used to store String, Boolean, and Integer.

Thanks for Sharing your Knowledge in advance.

General Grievance
  • 4,555
  • 31
  • 31
  • 45

2 Answers2

0

your app is crashing because item is null...you have to access this item from Menu object instance

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int myNumber=0;
    // Inflate the menu; this adds items to the action bar if it is present.

    getMenuInflater().inflate(R.menu.menu, menu);
    MenuItem item =(MenuItem) menu.findItem(R.id.lifeId);
    item.setTitle(String.valueOf(myNumber));
    return true;
}
tsiro
  • 2,323
  • 3
  • 24
  • 46
0

Add this:

menu.findViewById(R.id.lifeId).setTitle(String.valueOf(myNumber))
Nem
  • 26
  • 1