-3
これは私のコードであり、画像ファイルを挿入する際のエラーです。データベースに画像を挿入して取得する方法
SQLiteDatabase.openOrCreateDatabase("AddDetail", null);
db1.execSQL("CREATE TABLE IF NOT EXISTS profile(name TEXT,photo BLOB); ");
Bitmap image= BitmapFactory.decodeResource(getResources(),R.drawable.file);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG,100,stream);
byte imageInByte[]=stream.toByteArray();
db1.execSQL("INSERT INTO profile VALUES('Ramesh',"+imageInByte+");");
Cursor s= db1.rawQuery("Select * from profile",null);
while(s.moveToNext()){
jtv.setText(s.getString(0));
byte[] image1= s.getBlob(1);
Bitmap bmp= BitmapFactory.decodeByteArray(image1,0,image1.length);
jim.setImageBitmap(bmp);
}
なぜデータベースに画像のビットマップを保存したいのですか? –
ちょうど新しいものを学ぼうとする –
いいですが、画像のビットマップの代わりに画像URLを保存してみてください。 –