How to read and write JSON from file with Gson

You can save JSON when you call web service. You must use the same methods which was used last item.

When you read this JSON, you must use Gson library.

http://howtodoinjava.com/wp-content/uploads/2014/06/google-gson.jpg
Download Gson Library.

public void returnJSONToYourModel() {
		final String json = Utils.readFromFile(MainActivity.this);
		final Gson gson = new Gson();
		final YourModel yourModel = gson.fromJson(json, YourModel.class);

	}

Download code.

Leave a Reply

Your email address will not be published. Required fields are marked *