Adding a Suspect to the Model Layer
Next, return to Crime.java and add a new JSON constant and a member variable to give Crime a field that will hold the name of a suspect. Also, modify the JSON methods to serialize the suspect into and out of JSON code and add new accessor methods.
Listing 21.2 Adding suspect field (Crime.java
)
public class Crime { ... private static final String JSON_PHOTO = "photo"; private static final String JSON_SUSPECT = "suspect"; ... private Photo mPhoto; private String mSuspect; public Crime(JSONObject ...
Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.