Lectures‎ > ‎Week 5:June 27-July 3‎ > ‎

03-Working with Data - Local and Remote

Homework required in preparation for this lecture

  1. Read the article about Data Storage on the Android site
    1. Write a short report explaining all the options that exist for data storage and an example of how each might be used. 
    2. Don't copy the article, create your own examples and your own explanation. Come up with examples from your own programs (i.e. incubator and PAs)
    3. Deliverable: 2-5 paragraph report
  2. Complete PA4 if you haven't already!

Weekly Programming assignments

  • Review last week's PA - have students demo their PA4's
  • DIscuss this week's PA - suggestion to use MVC approach, how would this work???

Mobile App Architecture

  • Remember from second lecture: activities get created and destroyed. Need to create illusion of continuity
  • Remember from first lecture: Many/most mobile applications will have a server component - remote data
  • In fact, users' Conceptual Model probably does not make a distinction between the two

What kinds of data?

  • Files, documents, text, images, video, music, anything
  • Code, compiled code or source code
  • Commands sent over the net (APIs)
  • Need to consider the 'format' of the data - XML, JSON, MP3, etc.
  • Need to consider the 'character encoding' of the data? What is this? Unicode.

Local data

  • Local, persistent data. Includes the application OS
  • Also of course application state
  • DiscussionWhat happens when I turn the power off and then back on, if there's no network?

Remote data

  • Browsing on the mobile device. Accessed 'live' over network connection
  • Data that lives 'on the server'
  • The world of Web Services
  • HTTP and REST
  • Architecture of Server vs. Client connection
  • Security issues
  • Firewall issues

Tour of Android's facilities

  • Shared Preference:  
    • Only primitive types - booleans, floats, ints, longs, and strings
    • How could you save something bigger than a primitive type?
    • Across all parts of one Application (using application Context)
    • Persist across sessions
    • Privacy?
    • Discussion: What are the preferences each incubator project will need to store ????
  • Internal Storage
    • Persistent 'file' storage
    • Uses standard Java file primitives
    • Stays with the application. Uninstalled with application too!
    • Special handling for 'cache' files. What's a cache? How might the handling be different? See GetCacheDir
    • Discussion: What are some applications of Internal Storage and cacheing? When might you use them in your incubator projects? How about in extensions of the PA projects?
  • External Storage
    • Not exactly 'external'. Maybe 'external to the application'
    • Can be a memory stick, but also can be internal to the device
    • More like a global (to the device) file system
    • Note special 'sections' for specific types of files (e.g. Music etc.)
    • Discussion: What might you store in external storage for your incubator applications or the PAs?
  • Databases
    • Full fledged SQL Database, built in - SQLite
    • Good for managed (transactional) structured (tabular) data
    • Implemented as a library not as a separate service
    • "Manifest Typing" - columns don't have a specific data type
    • Primarily used within one application
    • Discussion: Do you really need SQL? How could you redesign your application to use one of the other storage mechanisms? What are the advantages/disadvantages of each approach?
  • Content Providers
    • Abstraction to separate access from storage
    • URI based. e.g. content://edu.brandeis.provider.groceries/prices/5
    • Principal way to allow data interchange between applications
    • Need to be registered with Android OS
    • Some ContentProviders are built-in, e.g. Contacts
    • Examples of accessing phonebook info here
    • Example of showing image thumbnails of images stored on SD is here
    • Example of building a content provider is here
    • Discussion: Which built-in content providers might your incubator application use? What are the pros and cons of making application data accessible to other applications? What other applications could be created that would use information generated by your incubator application?
  • Web-based storage

Discussion

  • Imagine adding features to your app similar to the following FourSquare features:
    • A web site where users can create an account
    • An Android app where users can log into their account
      • A "Check in here" button
      • When clicked, if anyone else who is a member is in the same place, you get a message on the Android screen: "Pito Salas is also here"
      • If "here" doesn't have a name, user gets a chance to give it a name, e.g. "Volen 101"
      • If "you" have been "here" more often than anyone else, you become the "Mayor"
      • An administrator on the server can see a map of all "places" and the current people "checked in"
  • Discussion: Let's explore together what the mobile architecture for this system might look like. Would this be interesting for your application? 

Afternoon:
Spend 3 hours (1-4) working on incubator project.
Try to get the most important feature of your sprint completed today!
Demo your progress at 3:45 (5 minutes/group)!