Challenge: Deleting Photos

Right now, you can replace a Crime’s photo, but the old file will continue to take up space on disk. Add code to CrimeFragment’s onActivityResult(int, int, Intent) method to check the crime for an existing photo and delete that file from disk.

For another challenge, give users the power to delete a photo without having to replace it. Implement a context menu and/or a contextual action mode in CrimeFragment that is triggered by long-pressing the thumbnail image. Offer a Delete Photo menu item that deletes the photo from the disk, the model, and the ImageView.

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.