ActiveAndroid Not saving blob type data(Image) in Sqlite

非 Y 不嫁゛ 提交于 2019-12-13 07:50:05

问题


This is My model class ...i want to insert image file in db using activeandroid .i converted image file into bytes ... but bytes is not stored in Db ... the field type in Table is Blob

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;

@Table(name = "contact")

public class Contact extends Model {
    @Column(name = "ID")
    private int ID;
    @Column(name = "NAME")
    private String name;
    @Column(name = "PHOTO")
    private String photo;
    @Column(name = "TITLE")
    private String title;
    @Column(name = "PHONE")
    private String phone;
    @Column(name = "EMAIL")
    private String email;
    @Column(name = "MEMO")
    private String memo;
    @Column(name = "Image")
    private byte[] _image;`

回答1:


AA supports saving byte arrays and defining custom type serializer maybe could help you.From performance view, its more useful create a column as a string and get the image from the disk or the web.



来源:https://stackoverflow.com/questions/31531141/activeandroid-not-saving-blob-type-dataimage-in-sqlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!