Android ObjectInputStream and ObjectOutputstream snippet

At first, make your object serializable and let the IDE (in my case Eclipse) generate a serialVersionUID for you:

public class Post implements Serializable{

	private static final long serialVersionUID = 7884946435027239199L;

	public String firstname;

	public String lastname;


Writing to files with serialization and writing objects to file:

FileOutputStream fileOutputStream = openFileOutput("personobject", Context.MODE_PRIVATE);
ObjectOutputStream objectOutputStream= new ObjectOutputStream(fileOutputStream );

Reading files with serialization and get it as object:

FileInputStream fileInputStream = openFileInput("personobject");
ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
Person person = (Person)objectInputStream.readObject();

Thats it!


How to include ActionBarSherlock in your Android-Project

If you have problems to include ActionBarSherlock in your Android project (because of not generated or something) then follow this quick guide:

Include ActionBarSherlock as library in your Eclipse-Workspace.

Both project needs to compile with Android 4.0 or newer. And you must  specify a targetSdkVersion of 11 or higher in your application’s manifest .


If you want to develop for Android 2.1 then add this to your application’s manifest and also build your app with api-level 15 (Android 4.0.3)

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>

Finally select “Project” -> “Clean” -> “Clean all projects” in Eclipse.