1 / 9

lec 05

lec 05. Admin stuff; schedule IOS versus Android Preferences Configuration Changes Advanced UI. You can persist data in several ways :. Preferences : key/value pairs SQLite : Use a very small RDBMS that is sandboxed to your app and then expose it to other apps using a content provider

jhamann
Download Presentation

lec 05

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. lec 05 Admin stuff; schedule IOS versus Android Preferences Configuration Changes Advanced UI

  2. You can persist data in several ways : Preferences: key/value pairs SQLite: Use a very small RDBMS that is sandboxed to your app and then expose it to other apps using a content provider Files: You can read/write files to your raw directory-- avoid this. Network: store data on the internet and read/write using any available Internet protocol – avoid this.

  3. You must declare an object called SharedPreferences SharedPreferences shp; Assign it like so: shp = PreferenceManager.getDefaultSharedPreferences(this); Access elements like so: String strName = shp.getString("name_key", ""); Put elements like so: SharedPreferences.Editor sheEditor = shp.edit(); sheEditor.putString("name", "Rumpelstilskin"); sheEditor.commit();

  4. Configuration Changes aka rotate screen To force rotate a screen in emulator, press cntrl-F12 (on PC)

  5. Usually you restore your state in onCreate. It is possible to restore it in onRestoreInstanceState as well, but not very common. (onRestoreInstanceState is called after onStart, whereas onCreate is called before onStart. Use the put methods to store values in onSaveInstanceState: protected void onSaveInstanceState(Bundle icicle) { icicle.putLong("param", value); super.onSaveInstanceState(outState); } And restore the values in onCreate: public void onCreate(Bundle icicle) { if (icicle != null){ value = icicle.getLong("param"); } }

  6. Student presentations: A: AsyncTask: How to get/parse JSON data (weather data) from RESTful web service (with recipe) B: MediaStore: Taking pictures and videos and storing them for use in an app (not the standard gallery) (with recipe) C: Voice Recognition: How to use voice recognition inside an app (with recipe) D: Tracking locations (using GPS) for a jog or a race. Data capture so that I can map where I went and how far I traveled, avg speed (with recipe)

More Related