FileDocCategorySizeDatePackage
Persist.javaAPI DocAndroid 1.5 API2237Wed May 06 22:42:42 BST 2009com.android.calculator2

Persist

public class Persist extends Object

Fields Summary
private static final int
LAST_VERSION
private static final String
FILE_NAME
private android.content.Context
mContext
History
history
Constructors Summary
Persist(android.content.Context context)


      
        this.mContext = context;
        load();
    
Methods Summary
private voidload()

        try {
            InputStream is = new BufferedInputStream(mContext.openFileInput(FILE_NAME), 8192);
            DataInputStream in = new DataInputStream(is);
            int version = in.readInt();
            if (version > LAST_VERSION) {
                throw new IOException("data version " + version + "; expected " + LAST_VERSION);
            }
            history = new History(version, in);
            in.close();
        } catch (FileNotFoundException e) {
            Calculator.log("" + e);
        } catch (IOException e) {
            Calculator.log("" + e);
        }
    
voidsave()

        try {
            OutputStream os = new BufferedOutputStream(mContext.openFileOutput(FILE_NAME, 0), 8192);
            DataOutputStream out = new DataOutputStream(os);
            out.writeInt(LAST_VERSION);
            history.write(out);
            out.close();
        } catch (IOException e) {
            Calculator.log("" + e);
        }