b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK)
{
selectedImage = data.getData();
bmImage.setImageURI(selectedImage);
}
}
b3 = (Button)findViewById(R.id.add);
b3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor c = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if(c == null) return;
c.moveToFirst();
int columnIndex = c.getColumnIndex( MediaStore.Images.Media.DATA);
ImagePath = c.getString(columnIndex);
c.close();
byte byteImage1 [] = null;
try{
FileInputStream instream = new FileInputStream(ImagePath);
BufferedInputStream bif = new BufferedInputStream(instream);
byteImage1 = new byte[bif.available()];
bif.read(byteImage1);
Log.d("Byte Value",""+byteImage1.length);
}catch (IOException e) {
}
d = h.getWritableDatabase();
ContentValues cv =new ContentValues();
cv.put(h.IMAGE_DATA, byteImage1);
d.insert(h.IMAGE_TABLE, null,cv);
d.close();
Toast.makeText(getApplicationContext(), "Save", 6).show();
}
});
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK)
{
selectedImage = data.getData();
bmImage.setImageURI(selectedImage);
}
}
b3 = (Button)findViewById(R.id.add);
b3.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor c = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if(c == null) return;
c.moveToFirst();
int columnIndex = c.getColumnIndex( MediaStore.Images.Media.DATA);
ImagePath = c.getString(columnIndex);
c.close();
byte byteImage1 [] = null;
try{
FileInputStream instream = new FileInputStream(ImagePath);
BufferedInputStream bif = new BufferedInputStream(instream);
byteImage1 = new byte[bif.available()];
bif.read(byteImage1);
Log.d("Byte Value",""+byteImage1.length);
}catch (IOException e) {
}
d = h.getWritableDatabase();
ContentValues cv =new ContentValues();
cv.put(h.IMAGE_DATA, byteImage1);
d.insert(h.IMAGE_TABLE, null,cv);
d.close();
Toast.makeText(getApplicationContext(), "Save", 6).show();
}
});
No comments:
Post a Comment