maybe I didnt explain enough :)

so what I want to is to serialize an Object in order to deserialize it later on.

but its not that easy.

I think the way I try to write is ok.

but why do i get that exception?

its only an in, a double and a string inside that object.

greetings,
darolla

2009/2/10 DaRolla <netzprofi.ma...@googlemail.com>:
>
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to