Lab - Working with Media and the File System
Mission: In this lab assignment, you will use the camera to add an image to your fugitive. You will save the image to the file system, and provide a url to the database for easy retrieval. You will also learn how to repopulate your database with remote data.
Specification: Start with the TiBountyHunter project you created for the last assignment. You will now add the camera function and mechanisms to support taking a picture, saving it, and retrieving it for viewing in a detail window. To successfully complete this lab, you must develop an application that meets the following description:
- Add a button in the detail view to snap a picture with the camera.
- Save the image to the file system and in the database as a url.
- Extend the database model with the addPhoto function
- Extend the UI with the needed buttons and images
|1. Open the TiBountyHunter project you created for the last assignment, or download the starting point code and import it as a new project in Studio: http://assets.appcelerator.com.s3.amazonaws.com/app_u/code/TiBH260.zip|
|2. Edit the lib/db.js file.
|Because you're changing the database and we're not writing any alter-table statements, you will need to uninstall the app from the simulator/emulator. If you're starting a new project rather than editing your earlier work, this won't be a problem for you.|
|3. Edit the ui/common/DetailWindow.js file.
|4. Make sure to update the internationalization strings.xml file.|
|5. Build your app for the iOS simulator or Android emulator. Add images to the photo gallery. Test the Add Photo functionality. Correct any problems that exist.|
|Don't forget to uninstall the old version of the app before running the new version.|
In this lab, you added images and support for the camera or photo gallery to TiBountyHunter. You saved those images to the local file system, and saved the path to those images in the database to limit the chances of over-consuming memory when you later read that database.
- API docs: Media: http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Media
- API docs: Filesystem http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.Filesystem
- Guides: Filesystem Access and Storage: http://docs.appcelerator.com/titanium/2.0/index.html#!/guide/Filesystem_Access_and_Storage
- Finished code: See the next lab or GitHub