At attempt to deserialize the data such error takes off. It flies in the following line:
ObjectInputStream ois = new ObjectInputStream(fis); But the code of the entire method (bookPrefs - the SharedPreferences, books - ArrayList with objects of the custom, serializable class.):
void loadBooks(){ StringBuilder bytes = new StringBuilder(); // FIXME: 06.03.2017 Здесь тоже убрать создание объекта. //Файл для десериализации File f = new File(PATH_TO_DESERIALIZABLE_DATA); bookPrefs = getActivity().getPreferences(MODE_PRIVATE); bytes.append(bookPrefs.getString(PREFS, "")); //Запись байтов в файл try (Writer writer = new OutputStreamWriter(new FileOutputStream(PATH_TO_DESERIALIZABLE_DATA))) { writer.write(bytes.toString()); } catch (FileNotFoundException e){ Toast.makeText(getActivity(), "FileNotFound!", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } catch (IOException e){ Toast.makeText(getActivity(), "IOException with load", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } //Десериализация try { FileInputStream fis = new FileInputStream(PATH_TO_DESERIALIZABLE_DATA); // FIXME: 06.03.2017 ДЕСЕРИАЛИЗАЦИЯ ObjectInputStream ois = new ObjectInputStream(fis); books = (ArrayList<Book>) ois.readObject(); } catch (ClassNotFoundException e){ Toast.makeText(getActivity(), "Class nf", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } catch (IOException e){ Toast.makeText(getActivity(), "IOException with deser", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } }