如何将图像从sqlite插入到listview

时间:2017-01-15 03:06:00

标签: android listview android-sqlite android-imageview

这是我的数据库助手活动:

public List<Product> getListProduct() {
    Product product = null;
    List<Product> productList = new ArrayList<>();
    openDatabase();
    Cursor cursor = mDatabase.rawQuery("SELECT * FROM Product", null);
    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        product = new Product(cursor.getInt(0), cursor.getString(1), cursor.getDouble(2), cursor.getString(3));
        productList.add(product);
        cursor.moveToNext();

    }
    cursor.close();
    closeDatabase();
    return productList;
}

我使用sqlite作为我的数据库,我希望它出现在项目名称旁边的listview中。任何想法如何?

1 个答案:

答案 0 :(得分:0)

全尺寸图片太大而无法粘贴在SQLite数据库中,更不用说Intent了。他们需要一个可以存放在设备文件系统中的地方。 通常,您会将它们放在私人存储中。回想一下,您使用私有存储来保存SQLite数据库。使用像

这样的方法
Context.getFileStreamPath(String)

Context.getFilesDir() 

你也可以用常规文件做同样的事情(它会存在于 与您的SQLite数据库所在的databasessubfolder相邻的子文件夹。)