0

当我单击菜单项时,我正在尝试保存自定义对象。问题是它的崩溃。在我们开始之前,当我尝试在另一个活动中读取该数据时,它也会崩溃。这是我试图保存数据的代码:

这是一个 pastebin链接

    my write function in the menu

myInfo.setOnMenuItemClickListener(new OnMenuItemClickListener()
{
  public boolean onMenuItemClick(MenuItem item)
  {
     Intent ourIntent = new Intent(Results.this, listTimes.class);
     ourIntent.putExtra("Meeting", meetingObj);

     try {
     fos = new FileOutputStream(filename);
     oos = new ObjectOutputStream(fos);
     oos.writeObject(businesses.get(positionChecked));

     } catch (FileNotFoundException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
     } catch (IOException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
     }
      finally
     {
      try {
      oos.close();
      fos.close();
     } catch (IOException e) {
                                                // TODO Auto-generated catch block
                                                e.printStackTrace();
                                        }
                                }

                                //startActivity(ourIntent);
                                return true;
                        }


// My read function

private void getData()
        {
                try {
                        fis = openFileInput(filename);
                        ois = new ObjectInputStream(fis);
                        business = (Business) ois.readObject();
                } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (StreamCorruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (ClassNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                finally
                {
                        try {
                                ois.close();
                                fis.close();
                        } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                }

        }
4

0 回答 0