我想将图像保存在sqlite中。在这种方法中,我将图像路径转换为字符串。我的问题是如何将其转换为byte []格式。
if (resultCode == RESULT_OK) {
// we need to update the gallery by starting MediaSanner service.
mScanner = new MediaScannerConnection(ImagePreviewActivity.this,new MediaScannerConnection.MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
mScanner.scanFile(imageUri.getPath(), null );
}
public void onScanCompleted(String path, Uri uri) {
mScanner.disconnect();
if (path.equals(imageUri.getPath())) {
photoPath=imageUri.getPath();
ImagePreviewActivity.this.runOnUiThread(new Runnable() {
public void run() {
capture_photo = (ImageView) findViewById(R.id.caturePhoto);
Bitmap myBitmap = BitmapFactory.decodeFile(photoPath);
capture_photo.setImageBitmap(myBitmap);
}
});
mScanner.disconnect();
}
}
});
mScanner.connect();
Run Code Online (Sandbox Code Playgroud)