开发者

using Android, is there a significant performance hit to store small images as BLOBs in SQLite?

I have about fifty 10kb images that each have a text description and location coordinates.

I have two choices:

  1. I can store the images as BLOBs in the SQLite db togather with the texts
  2. I can store the images on SDRAM and store the path to the images in the DB
  3. 开发者_运维知识库

method (1) seems to be for convenience, but I wonder if there are any negatives to using this approach. For example, would the db respond slower ?


I went for method #2 because the kvPairs.put(FieldsLocation.IMAGE, recloc.mImage); in the code below results in a compilation error - which surprised me. I also tried recloc.mImage.clone()

public long insertLocation(RecordLocation recloc)
{
    Long lValueToReturn;

    ContentValues kvPairs = new ContentValues();
    kvPairs.put(FieldsLocation.LATITUDE,    recloc.mLat);
    kvPairs.put(FieldsLocation.LONGITUDE,   recloc.mLon);
    kvPairs.put(FieldsLocation.DESCRIPTION, recloc.mDescription);
    kvPairs.put(FieldsLocation.IMAGE,       recloc.mImage);

    lValueToReturn = mDB.insert(TABLE_NAME_LOCATIONS, null, kvPairs);

    return lValueToReturn;
}


public class RecordLocation
{
    public double mLat;
    public double mLon;
    public String mDescription;
    public Byte[] mImage;

    public RecordLocation()
    {
    }
}


final public class FieldsLocation
{
    //column names
    public static final String LOCATIONID = "_id";
    public static final String LATITUDE = "latitude";
    public static final String LONGITUDE = "longitude";
    public static final String DESCRIPTION = "description";
    public static final String IMAGE = "image";

    private FieldsLocation()
    {
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜