First things first: Read this to know what kind of options you have.
Now to answer your question on how to save data on locally some code from here:
String FILENAME = "hello_file";
String yourJSON = downloadedJSON.toString() // depends what kind of lib you are using
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(yourJSON.getBytes());
fos.close();
Store the FILENAME in the SharedPreferences
so that you can read it later in case it changes or just to learn how to store data in SharedPreferences
:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); // PREFS_NAME should be a static final String property
SharedPreferences.Editor editor = settings.edit();
editor.putString("myFileName", FILENAME).commit();
Then when you reopen the app later you can do it like this:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
String FILENAME = setting.getString("myFileName", "");
if (!FILENAME.isEmpty()) {
readFile(FILENAME);
}
And finally read the file back as String
from here:
FileInputStream fis;
fis = openFileInput("test.txt");
StringBuffer fileContent = new StringBuffer("");
byte[] buffer = new byte[1024];
while ((n = fis.read(buffer)) != -1) {
fileContent.append(new String(buffer, 0, n));
}
Try to understand each block of code before you use this code. Go through the Android Documentation and use Google if you are stuck. Plenty of tutorials out there. Data Storage is fundamental and not just for Android!