NullPointerException
NullPointerException

Reputation: 37627

How to serialize only certains elements of a object?

i want to serialize this class, to store it on the sdcard of the phone, but i want to serialize all but the bitmaps, the bitmaps must be not stored and must be null when the class is loaded again from the sdcard into a object (unserialized)

How it is possible to serialize all but the bitmaps?

this is my code:

public class Page implements Serializable{
String src;
String id;
String thumbnail;
public ArrayList<Area> areas;   
public Bitmap pageBitmap;
public Bitmap thumbnailBitmap;
}

I know how to store a object on the sdcard, and i know that this object must be serializable, but when i do it, it is trying to store the bitmaps also, but i dont want that.

Upvotes: 1

Views: 97

Answers (1)

Jave
Jave

Reputation: 31846

Use the transient keyword:

public transient Bitmap pageBitmap;

Upvotes: 7

Related Questions