I have a config.json file in the asset folder in my application. Now the scenario is, I will pull a JSON content from server and will update(override) the config.json file stored in asset folder. How can I achieve this? Here is sample of JSON:
{
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
I am able to read the file from the asset folder. But how to write in that file?:
public String loadJSONFromAsset() {
String json = null;
try {
InputStream is = getActivity().getAssets().open("config.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return json;
}