主要
请帮助我尝试将图像存储为sqlite中的blob但是我得到了字符串格式我不知道我做错了什么..
public byte[] photo=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button insert=(Button)findViewById(R.id.insert);
final SQLiteDatabase db;
db=openOrCreateDatabase("demo", Context.MODE_PRIVATE, null);
db.execSQL("create table if not exists demo1(Dp BLOB );");
insert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Bitmap b=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//ContentValues cv=new ContentValues();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.PNG, 90, bos);
photo=bos.toByteArray();
db.execSQL("INSERT INTO demo1(Dp)VALUES('"+photo+"')");
}
});
}