0

I had a class called Items with is implement with Serializable, however when it's come to read data the system prompted me an error on NotSerializableException on Item class (as image link below) which is not exist in my project instead of Items class. I've tried to rebuild and clean the project but it's still same. Appreciate for the help as i got no clue at all..

public class Items implements Serializable {
   private String item;
   private String date;

   public Items(String item, String date) {
      this.item = item;
      this.date = date;
   }

   public String getItem() {
      return item;
   }

   public void setItem(String item) {
      this.item = item;
   }

   public String getDate() {
      return date;
   }

   public void setDate(String date) {
      this.date = date;
   }
}

Image as below:

Error on NotSerializableException image

Simon23
  • 3
  • 1

1 Answers1

0

I do not have rights to comment so writing as an answer.

Please try regenerating the file with Items object and then try deserialize it. May be the file is old and it was created using Item class instead of Items.

Mohit Bansal
  • 348
  • 3
  • 8
  • i just try deleted the Items class file and regenerating the Items class file again without serialize, however when I debugging my code, it's still pointing me on the **Item** class is not serialize instead of the new **Items** class....... – Simon23 Nov 03 '19 at 06:18
  • Sigh. I was referring to re-create the data file which you are deserializing. I think that file is created using Item class. – Mohit Bansal Nov 03 '19 at 06:28
  • gosh, I uninstall the app in my simulator and re-install,now it working..anyway thanks! – Simon23 Nov 03 '19 at 06:37