vendredi 19 février 2016

ActiveAndroid not supporting byte[]?

Since it is faster to save Bitmaps as byte[] rather than as String in the database, I was trying to do that for my project. However it seems that byte[] are not supported by ActiveAndroid. Here is my code (the columns are not created -> yes I had them as String before, but I reinstalled my App to make sure that this won't cause any trouble):

@Table(name = "Image")
public class Image extends Model {
@Column(name = "Image_data")
public byte[] imageData;

@Column(name = "Thumbnail_data")
public byte[] thumbnailData;

public Day day() {
    return (Day)getMany(Day.class,"Day").get(0);
}

public Image(byte[] imageData, byte[] thumbnailData) {
    super();
    this.imageData = imageData;
    this.thumbnailData = thumbnailData;
}

public Image() {
    super();
}

}

I am using the beta version of ActiveAndroid (downloaded as .jar):

compile files('libs/activeandroid-3.1-beta.jar')

I thought that using the beta version could cause this problem so I changed my build.gradle as it is shown on their github page:

repositories {
mavenCentral()
maven { url "http://ift.tt/1ca5iuY" }
}

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'

Unfortunately this doesn't work either. I hope it is possible to store byte[] as BLOB in ActiveAndroid. If not it would be very interesting to hear about alternatives.

Aucun commentaire:

Enregistrer un commentaire