More Persistence




CS185c

Chris Pollett

Sep. 28, 2009

Outline

Introduction

More Intro

iPhone Filesystem Test

Android FileSystem Test (Read Part)

Android FileSystem Test (Write Part)

FileOutputStream fos = null;
try
{
   fos = this.openFileOutput("filename.txt", Context.MODE_PRIVATE);
   fos.write("hi there\n".getBytes());
   Log.i("AndroidPersistence", "I just wrote stuff\n");
}
catch (IOException ie)
{
   Log.e("AndroidPersistence", "File Write Error");
}
finally
{
   if(fos !=null) 
   {
      try {fos.close();} catch(Exception e) {}
   }
}

Quiz

To create an informational log entry in Android:

  1. You call the android.util.NSLog() method with a String.
  2. You call android.util.Log.v() with a String.
  3. You call android.util.Log.i() with a String.

SQLite

Database Commands

SQLite on the iPhone

Executing Commands on an SQLite Database on the iPhone