sqlite 存储图片
发布时间:2020-12-12 23:54:36 所属栏目:百科 来源:网络整理
导读:1、bitmap保存到SQLite 中 数据格式: Java代码 db.execSQL( "Createtableexpress(_idINTEGERPRIMARYKEYAUTOINCREMENT,express_novarchar(100),express_nameTEXT,express_imgBLOB);" ); 2、bitmap 变为 Blob ContentValuesvalues= new ContentValues(); Bitm
1、bitmap保存到SQLite 中 数据格式: Java代码
2、bitmap 变为 Blob ContentValuesvalues=newContentValues();3、从SQLite中读取Bitmap byte[]in=cur.getBlob(cur.getColumnIndex("express_img"));显示在ImageView上 ImageViewimageView=(ImageView)view.findViewById(R.id.img);总结: inputStream: 作为数据缓存,数据写如何供别的对象读取,其方法为read(); outputStream:作为数据缓存,将来向别的对象写内容!其方法write(); byte[]in=cur.getBlob(cur.getColumnIndex(MyUser.User.BITMAP_VALUES));//这样也可以对数据进行初始化,byte是基本类型,不需要之前进行长度定义。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |