jason flanagan
jason flanagan

Reputation: 117

How to save an int to a file and then read it back in android

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

Answers (2)

Kasia
Kasia

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

Itay
Itay

Reputation: 219

You should use sqlite DataBase:

Tutorial

Upvotes: 1

Related Questions