解决方法
首先,convert bitmap to byte array
Bitmap bmp = intent.getExtras().get("data"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG,100,stream); byte[] byteArray = stream.toByteArray();
稍后,将byte []保存到Realm中
注意:字符串和字节数组(byte [])不能大于16 MB(来自Realm文档)
字段类型
Realm supports the following field types: boolean,byte,short,ìnt,long,float,double,String,Date and byte[]. The integer types byte,int,and long are all mapped to the same type (long actually) within Realm. Moreover,subclasses of RealmObject and RealmList are supported to model relationships.
原文地址:https://www.jb51.cc/android/317851.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。