Backing up user data in Note to Self
So, with our newfound insight into exceptions, let's modify our Note to Self code, and then we can be introduced to the JSONObject and JSONException classes.
First, let's make some minor modifications to our Note class. Add some more members that will act as the key in a key-value pair for each aspect of our Note class:
private static final String JSON_TITLE = "title"; private static final String JSON_DESCRIPTION = "description"; private static final String JSON_IDEA = "idea"; private static final String JSON_TODO = "todo"; private static final String JSON_IMPORTANT = "important";
Now add a constructor and an empty default constructor that receives JSONObject and throws JSONException. The body of the constructor initializes each of the members that defines the properties of a single Note object by calling the getString or getBoolean method of JSONObject, passing in the key as an...