Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem serializing Drawable
    primarykey
    data
    text
    <p>I've got a singe object which has three fields: two strings and a <code>Drawable</code></p> <pre><code>public class MyObject implements Serializable { private static final long serialVersionUID = 1L; public String name; public String lastName; public Drawable photo; public MyObject() { } public MyObject(String name, String lastName, Drawable photo) { this.name = name; this.lastName = lastName; this.photo = photo; } } </code></pre> <p>What I'm trying to do, is to save an <code>ArrayList</code> of these objects to a file, but i keep getting a <code>NotSerializableException</code></p> <pre><code>02-02 23:06:10.825: WARN/System.err(13891): java.io.NotSerializableException: android.graphics.drawable.BitmapDrawable </code></pre> <p>The code which I use to store the file:</p> <pre><code>public static void saveArrayList(ArrayList&lt;MyObject&gt; arrayList, Context context) { final File file = new File(context.getCacheDir(), FILE_NAME); FileOutputStream outputStream = null; ObjectOutputStream objectOutputStream = null; try { outputStream = new FileOutputStream(file); objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.writeObject(arrayList); } catch(Exception e) { e.printStackTrace(); } finally { try { if(objectOutputStream != null) { objectOutputStream.close(); } if(outputStream != null) { outputStream.close(); } } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>Everything works fine when the drawable isn't initialized. Thanks in advance for any help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload