i'm new to android json and just starting working on it as in place of sqllite databse ,
i want user to input data into edit text and it go and save into the json array like we use to do in the sqllite databse by table
queryValues.put("studentid", studentId);
queryValues.put("roll", roll.getText().toString());
queryValues.put("name", name.getText().toString());
queryValues.put("class", Class.getText().toString());
queryValues.put("marks", marks.getText().toString());
data.updatestudent(queryValues);
so is there any way that we can make user to input data from edit text and then it go save into json Array and also user can do update and delete operations.
or if there is anyother way , guide me into that direction . Also i can't find any good example of json .
Try it this way:
Before you make a call to the below function, make sure that your edit text does not return null. Use basic validations.
public JSONArray makeJSON() {
JSONArray jArr = new JSONArray();
JSONObject jObj = new JSONObject();
try {
jObj.put("customer_name", edittex1.getText().toString);
jObj.put("serial_number", edittex2.getText().toString);
jObj.put("membership_number", edittex3.getText().toString);
jObj.put("brand_name", edittex4.getText().toString);
jObj.put("model_number", edittex5.getText().toString);
jObj.put("IMEI_number", edittex6.getText().toString);
jObj.put("handset_purchase", edittex7.getText().toString);
jObj.put("counter_name", edittex8.getText().toString);
jArr.put(jObj);
} catch (Exception e) {
System.out.println("Error:" + e);
}
return jArr;
}