开发者

Convert list in to byte[] for storing in SQLite in Android

I have this array declaration:

List<GeoPoint> race = new ArrayList<Ge开发者_StackOverflow社区oPoint>();

I want to store this array in to SQLite database.

Can some one give me code for converting this array in to byte[] or give me code for another solution ?

Thanks


If your GeoPoint is Serializable you can use a ByteArrayOutputStream plus an ObjectOutputStream.

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(list);
byte[] result = baos.toByteArray();
oos.close();

Resources :

  • ObjectOutputStream
  • ByteArrayOutputStream
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜