0
I have some files .json
in assets
.
I am currently reading only in these files.
Reading
public String loadJSONFromAsset(String Ajson) {
String json = null;
try {
InputStream is = context.getAssets().open(Ajson);
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;
}
How can I write on them? That is, replace all their content with another of my choice.
Nice, but I need to do this for the Java language, because I will consume from an API the new json script to replace with the old one in the file that is in Assets.
– CristianCotrena
It would take the new json of the API and place this json in a String, replace the existing content in the.json file with the content of this String.
– CristianCotrena
I reworked the answer, did it help you? Did it? Would you also like to know the writing process of the altered json? Hug!
– ℛɑƒæĿᴿᴹᴿ