简体   繁体   中英

Load JSON from assets and add it to JSONObject: Android

I need to store the user input and other string to a local storing method to use it later. Also I need to update it with data every time the user inputs other preferences and read it. I've chosen JSON for this task, hope it's the best option.

My problem is that every time I close the app (or update the app version) the file gets reset.

I would save the JSONObject to the internal storage and update, change, read and check for its existence every time the app starts.

This file is the core of my app as it stores the preferences.

UPDATE: I've used SharedPreferences to do my task:

SharedPreferences prefs = this.getSharedPreferences("com.example.app", Context.MODE_PRIVATE);

Ok, I've switched to using SharedPreferences. Thanks for your recommendations.

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