Hello darolla,
I have not tested your code to be certain about this but I would say u
would actually
need to instantiate your object like so instead of passing the static
reference
because the object u create in your code contains states (your
instance vars) but
the static reference does not.

Serialisiere s = new Serialisirer(1,2,3)
oos.writeObject(s)

On Feb 10, 5:50 am, Chechy <[email protected]> wrote:
> Hi,
>
> I've tried several ways but the only way I succeeded to serialize
> something is to serialize each member of class Serialisiere:
>
>         public void writeIt(String filename) throws IOException {
>                 FileOutputStream fos = openFileOutput(filename,
> MODE_WORLD_WRITEABLE);
>                 ObjectOutputStream oos = new ObjectOutputStream(fos);
>
>                 oos.writeInt(this.i);
>                 oos.writeDouble(this.d);
>                 oos.writeChars(this.s);
>                 oos.close();
>                 fos.close();
>         }
>
> I'm not sure if this answers your question.
>
> Best Regards: Chechy
>
> On Feb 10, 11:55 am, DaRolla <[email protected]> wrote:
>
> > hi,
>
> > I get nuts on this, who can help?
>
> > package de.test;
>
> > import java.io.FileOutputStream;
> > import java.io.IOException;
> > import java.io.ObjectOutputStream;
> > import java.io.Serializable;
>
> > import android.app.Activity;
> > import android.os.Bundle;
> > import android.util.Log;
> > import android.widget.TextView;
>
> > public class SerialisiereAndroidActivity extends Activity {
>
> >     @Override
> >     public void onCreate(Bundle savedInstanceState) {
> >         super.onCreate(savedInstanceState);
> >         setContentView(R.layout.main);
>
> >         try {
> >                 Serialisiere pi = new Serialisiere(3, Math.PI, "pi");
> >                 ((TextView) findViewById(R.id.tv1)).setText("Serialisiere:  
> >  " +
> > pi.toString());
> >                 pi.writeIt("pi.ser");
> >         }
> >         catch( Exception e) {
> >                 Log.d( "SerialisiereAndroidActivity", e.toString() );
> >         }
> >     }
>
> >     public class Serialisiere implements Serializable {
>
> >         private static final long serialVersionUID =
> > -3922493985071195239L;
>
> >         private int i;
> >         private double d;
> >         private String s;
>
> >         public Serialisiere(int i, double d, String s) {
> >                 this.i = i;
> >                 this.d = d;
> >                 this.s = s;
> >         }
>
> >         public void writeIt(String filename) throws IOException {
> >                 FileOutputStream fos = openFileOutput(filename,
> > MODE_WORLD_WRITEABLE);
> >                 ObjectOutputStream oos = new ObjectOutputStream(fos);
> >                 oos.writeObject(Serialisiere.this);
> >                 oos.close();
> >                 fos.close();
> >         }
>
> >         @Override
> >         public String toString() {
> >                 return "i=" + i + " d=" + d + " s=" + s;
> >         }
> >     }
>
> > }
>
> > the problem is:
>
> > oos.writeObject(Serialisiere.this);
>
> > this throws an java.io.NotSerializableException.
>
> > who can help me on this?
>
> > greetings,
> > darolla

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to