serializing custom objects to file and reading and deserializing it
===

i am trying to save a list of custom objects to a file. And then in other activities or on restart of application i don't need to parse all my data again, and do all the stuff i did on the startup the first time again, just deserialize that file. But the deserializing doesnt seem to work for me, and i don't know why. I think the saving data to a file works, because i create a file of 900 kb or so.

My list of objects that needs to be serialized:


    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.Comparator;
    import java.util.Date;
    import java.util.List;
    
    import com.hera.ontdekdelft.listclasses.ListData;
    
    
    	public class SimpleVenue implements Serializable, Comparable<SimpleVenue>{
    		/**
    		 * 
    		 */
    	private static final long serialVersionUID = 1L;
    	public int ID;
    	public String name;
    	public String category;
    	public String address;
    	public String city;
    	public String tip;
    	public String phone;
    	public String website;
    	public String foursquare;
    	public float latitude;
    	public float longtitude;
    	public String theme;
    	public String icon;
    	public String exception;
    	public List<SimplePhotos> photos = new ArrayList<SimplePhotos>();
    	public List<SimpleOpeningHours> openinghours = new ArrayList<SimpleOpeningHours>();
    	  
    	  //setters
    	
    public void setId(int id){
    	ID=id;
    }
    public void setName(String vname){
    name=vname;
    }	  
    public void setCategory(String icon){
    	if(icon.equals("eten.png") || icon.equals("uitgaan.png")  || icon.equals("koffie.png") || icon.equals("restaurant.png")){
    		category="food";
    	}else if(icon.equals("monument.png") || icon.equals("openbaar.png") || icon.equals("voeten.png")){
    		category="sights";
    	}else if(icon.equals("winkelen.png")){
    		category="shops";
    	}else{
    		category=null;
    	}
    }	  
    public void setAdress(String vaddress){
    address = vaddress;
    }	  
    
    public void setCity(String vcity){
    	city=vcity;
    	}	
    
    public void setTip(String vtip){
    	tip=vtip;
    	}
    public void setPhone(String vphone){
    	phone=vphone;
    	}
    public void setWebsite(String vwebsite){
    	website=vwebsite;
    	}
    
    public void setFoursquare(String vfoursquare_link){
    	foursquare=vfoursquare_link;
    	}
    public void setLatitude(float vlatitude){
    	latitude=vlatitude;
    	}
    
    public void setLongitude(float vlong){
    	longtitude=vlong;
    	}
    
    public void setTheme(String vtheme){
    	theme=vtheme;
    	}
    
    public void setIcon(String vicon){
    	icon=vicon;
    	}
    public void setException(String vexception){
    	 exception =  vexception;
    	}
    
    
    	@Override
    	public int compareTo(SimpleVenue another) {
    		// XXX Auto-generated method stub
    		return 0;
    	}
    	
    	public static Comparator<SimpleVenue> SimpleVenueThemeSelector = new Comparator<SimpleVenue>() {
    		@Override
    		public int compare(SimpleVenue sv1, SimpleVenue sv2) {
    
    			String compareTheme1 = sv1.theme.toUpperCase();
    			String compareTheme2= sv2.theme.toUpperCase();
    			String compareName1 = sv1.name.toUpperCase();
    			String compareName2= sv2.name.toUpperCase();
    
    			//ascending
    			int comp = compareTheme1.compareTo(compareTheme2); // comp themes
    			if(comp==0){ // same theme
    				comp= compareName1.compareTo(compareName2); // compare names 
    			}
    			return comp;
    			}
    	};
    }

and then how i try to save my file:

     try
    							        {
    									 FileOutputStream fos = openFileOutput("save.bin", Context.MODE_PRIVATE);
    									 ObjectOutputStream os = new ObjectOutputStream(fos);
    									 os.writeObject(serializeSimpleVenue(sv));
    									 os.close();							        }
    							        catch(Exception ex)
    							        {
    									Log.v("SimpleVenueList",ex.getMessage());
    							        	ex.printStackTrace();
    							        }
    							        Log.i("tijdlog serializing", "einde");

with:

     public static byte[] serializeSimpleVenue(List<SimpleVenue> sv) { 
    	        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
    	     
    	        try { 
    	          ObjectOutput out = new ObjectOutputStream(bos); 
    	          out.writeObject(sv); 
    	          out.close(); 
    	     
    	          // Get the bytes of the serialized object 
    	          byte[] buf = bos.toByteArray(); 
    	     
    	          return buf; 
    	        } catch(IOException ioe) { 
    	          Log.e("serializeObject", "error", ioe); 
    	     
    	          return null; 
    	        } 
    	      } 

and then i try to get my file again like this:

    final List<SimpleVenue> sv = (List<SimpleVenue>) loadClassFile(new File("save.bin"));

with loadclassfile:

    public List<SimpleVenue> loadClassFile(File f)
    	{
    	    try
    	    {
    	    	ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
    	    	List<SimpleVenue> o =  (List<SimpleVenue>) ois.readObject();
    	    	return o;
    	    }
    	    catch(Exception ex)
    	    {
    		Log.v("Address Book",ex.getMessage());
    	    	ex.printStackTrace();
    	    }
    	    return null;
    	}



I saw the save.bin in a tutorial, but should it be a .bin or .txt or something else or doesn't it matter?

But the real problem is that the deserializing doesn't work, when i try to use my sv later, i get a nullpointerexception...
Can anyone see why my code fails? and what do i need to change?