Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import java.io.FileOutputStream;

import java.io.ObjectOutputStream;

public class Main {

    public static boolean saveObject(Context context, Object data, String filename) {
        FileOutputStream out;
        ObjectOutputStream oout;
        try {
            out = context.openFileOutput(filename + ".odb", Context.MODE_PRIVATE);
            oout = new ObjectOutputStream(out);
            oout.writeObject(data);
            oout.flush();
            out.flush();
            oout.close();
            out.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}