保存阅读文件时,Android Emulator崩溃

时间:2013-11-05 06:08:26

标签: android android-listview android-emulator

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

这是一个pastebin link

    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();
                        }
                }

        }

0 个答案:

没有答案