简体   繁体   中英

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 .

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

You should use sqlite DataBase:

Tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM