Android Object Serialization saveObject(Context context, String fileName, Object obj)

Here you can find the source of saveObject(Context context, String fileName, Object obj)

Description

save Object

Declaration

public static void saveObject(Context context, String fileName,
            Object obj) throws IOException 

Method Source Code

//package com.java2s;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import android.content.Context;

public class Main {
    public static void saveObject(Context context, String fileName,
            Object obj) throws IOException {
        FileOutputStream fos = context.openFileOutput(fileName,
                Context.MODE_PRIVATE);
        ObjectOutput out = null;//from   ww  w . ja  v  a  2s.c o  m
        try {
            out = new ObjectOutputStream(fos);
            out.writeObject(obj);
            out.flush();
        } finally {
            out.close();
            fos.close();
        }

    }
}

Related

  1. objectToString(Object o)
  2. stringToObject(String s)
  3. getBytes(Serializable obj)
  4. deserialize(final File file, final long serialTtl)
  5. serialize(final File file, final Object o)
  6. writeObjectToFile(Object obj, String filePath)
  7. writeObjectToFile(Object obj, String filePath, boolean append)
  8. writeQueueToFile(Queue list, String filePath)
  9. ObjectToByte(Serializable obj)