I create Byte[] and also its displaying on ImageView. Now When i click on Button , IMAGE should go in DATABASE.. I am Confused to how to put logic in ContentValue.
else if (requestCode == 2) {
Uri selectedImage = data.getData();
String[] filePath = {MediaStore.Images.Media.DATA};
Cursor c = getContentResolver().query(selectedImage, filePath, null, null, null);
c.moveToFirst();
int columnIndex = c.getColumnIndex(filePath[0]);
String picturePath = c.getString(columnIndex);
c.close();
Bitmap thumbnail = (BitmapFactory.decodeFile(picturePath));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
imgPro.setImageBitmap(thumbnail);
}
And My Content Valued code is here
String name = iName.getText().toString();
String age = iAge.getText().toString();
String date = iDoB.getText().toString();
String gender = a1;
String ward = iWard.getText().toString();
try {
SQLiteDatabase db = helper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(WardRobe_Contact.KEY_NAME, name);
values.put(WardRobe_Contact.KEY_DOB, date);
values.put(WardRobe_Contact.KEY_AGE, age);
values.put(WardRobe_Contact.KEY_IDENTITY, a1);
values.put(WardRobe_Contact.KEY_PROFILE, ward);
values.put(WardRobe_Contact.KEY_IMAGE,"HERE HOW TO CAST IMAGE VIEW ??" );
long wardrobe_entry = db.insert(WardRobe_Contact.TABLE, null, values);
db.close(); // Closing database connection
Toast.makeText(getApplicationContext(), "Data Inserted Successfully", Toast.LENGTH_SHORT).show();
How can i cast to set image to Database.. please help me.. thanxx a lot in advance