@Override
protected
void
onActivityResult(
int
requestCode,
int
resultCode, Intent data) {
Toast.makeText(getBaseContext(),
"resultCode : "
+ requestCode, Toast.LENGTH_SHORT).show();
try
{
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), data.getData());
ImageView SelectesNC = (ImageView)findViewById(R.id.SelectedNC);
SelectesNC.setImageBitmap(bitmap);
ByteArrayOutputStream baos =
new
ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,
100
, baos);
byte
[] imageByte = baos.toByteArray();
Toast.makeText(getApplicationContext(),
"DB에?"
, Toast.LENGTH_SHORT).show();
<strong>dbHandler.insertImage(imageByte);
Toast.makeText(getApplicationContext(),
"DB에 저장성공"
, Toast.LENGTH_SHORT).show();
showImg();
Log.d(
"receive"
,
"blob : "
+
4
);
}
catch
(FileNotFoundException e){
e.printStackTrace();
Log.d(
"receive"
,
"blob : "
+
1
);
}
catch
(IOException e){
e.printStackTrace();
Log.d(
"receive"
,
"blob : "
+
2
);
}
catch
(Exception e){
e.printStackTrace();
Log.d(
"receive"
,
"blob : "
+
3
);
}
}
private
void
showImg() {
dbHandler =
new
DBHandler(
this
);
try
{
Cursor mCursor = db.rawQuery(
"select ncimg from members where "
+ code,
null
);
byte
[] image = mCursor.getBlob(mCursor.getColumnIndex(
"ncimg"
));
ImageView blobImg = (ImageView) findViewById(R.id.dbImg);
blobImg.setImageBitmap(BitmapFactory.decodeByteArray(image,
0
, image.length));
mCursor.close();
}
catch
(Exception e){
e.printStackTrace();
}
}