O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating the Model Layer

Figure 20.6 shows the relationship between CrimeFragment, Crime, and Photo.

Figure 20.6  Model objects and CrimeFragment

Model objects and CrimeFragment

Adding a Photo class

Create a new class in the com.bignerdranch.android.criminalintent package. Name it Photo and leave its superclass as java.lang.Object.

In Photo.java, add the fields and methods shown in Listing 20.8.

Listing 20.8  The Photo class (Photo.java)

.​.​.​

p​u​b​l​i​c​ ​c​l​a​s​s​ ​P​h​o​t​o​ ​{​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​J​S​O​N​_​F​I​L​E​N​A​M​E​ ​=​ ​"​f​i​l​e​n​a​m​e​"​;​

 ​ ​ ​ ​p​r​i​v​a​t​e​ ​S​t​r​i​n​g​ ​m​F​i​l​e​n​a​m​e​;​

 ​ ​ ​ ​/​*​*​ ​C​r​e​a​t​e​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required