title: Android Save object as blob in sqlite
body: <p>is this right. I have this <code>gridview</code>. I want to save its item as blob in sqlite. so when i open the list of save data in sqlite ill just load the save <code>items</code> and call <code>adapter.notifyDataSetChanged</code> to my <code>gridview</code></p>
  
  <p>I tried this one but I get <code>NotSerializableException</code> error</p>
  
  <p>List items = new ArrayList();</p>
  
  <pre><code>public static byte[] serializeObject(Object o) {
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
  
          try {
              ObjectOutput out = new ObjectOutputStream(bos);
              out.writeObject(o);
              out.close();
  
              // Get the bytes of the serialized object
              byte[] buf = bos.toByteArray();
  
              return buf;
          } catch (IOException ioe) {
              Log.e("serializeObject", "error", ioe);
  
              return null;
          }
      }
  </code></pre>
  
  <p>my insert row</p>
  
  <pre><code>public long insertRow(byte[] data) {
      /*
       * CHANGE 3:
       */
      // TODO: Update data in the row with new fields.
      // TODO: Also change the function's arguments to be what you need!
      // Create row's data:
      ContentValues initialValues = new ContentValues();
      initialValues.put(KEY_DATA, data);
  
      // Insert it into the database.
      return db.insert(DATABASE_TABLE, null, initialValues);
  }
  </code></pre>
  
  <p>then I insert the serialize object</p>
  
  <pre><code>myDB.insertRow(MyDBAdapter.serializeObject(items));
  </code></pre>
  
  <p>also i'm confuse. should i save the adapter or the list of items'?</p>