
There are certain use cases in android where you need to store and retrieve the data as a JSON(JavaScript Object Notation) object from a file. There is no such defined way of storing a JSON object in a file. Data is stored in a file in the form of a string and that string is parsed into JSON. Hence, there are several challenges in parsing a string into a JSON object. The first step is to create a variable which represents a file name. In the second step, create a file object using the File class in java. In the third step create the object of FileReader, FileWriter, BufferReader and BufferWriter and initialize them with the initial value of null. The FileReader and FileWriter objects are used to open the file in ‘read’ and ‘write’ mode respectively. Similarly, the BufferReader and BufferWriter objects are used to read and write from....