DoodleView Method saveImage

Method saveImage (Fig. 7.32) saves the current drawing to a file in the device’s gallery. Line 271 creates a filename for the image, then lines 274–276 store the image in the device’s Gallery by calling class MediaStore.Images.Media’s insertImage method. The method receives four arguments:

• a ContentResolver that the method uses to locate where the image should be stored on the device

• the Bitmap to store

• the name of the image

• a description of the image

267     // save the current image to the Gallery268     public void saveImage()269     {270        // use "Doodlz" followed by current time as the image name271        String name = "Doodlz" + System.currentTimeMillis() + ".jpg" ...

Get Android™ How to Program, Second Edition 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.