Reputation: 117
I am creating an app and I'm still very new to programming. I was looking around for a long time to find out, how to save an int to a file and then read it back later, but I found nothing. Here's the snippet:
int Money = 750;
Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
So when the button is pushed, the int should be saved to a file called Money.txt
.
Upvotes: 0
Views: 71
Reputation: 166
You can use Shared Preferences if value is used only in this app.
Explanation and example: http://developer.android.com/guide/topics/data/data-storage.html#pref
Upvotes: 2