【发布时间】:2019-03-12 20:03:20
【问题描述】:
请露出我的英语
如何将拍摄的图片上传到数据库中?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
camera = (ImageButton) findViewById( R.id.camera );
camera.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog = new Dialog( MainActivity.this );
dialog.setContentView( R.layout.camera_gallery );
dialog.setTitle( "Upload Image" );
dialog.setCancelable( true );
dialog.show();
capture = (Button) dialog.findViewById( R.id.capture );
download = (Button) dialog.findViewById( R.id.download );
capture.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE );
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
getFileUri();
i.putExtra(MediaStore.EXTRA_OUTPUT, file_uri);
startActivityForResult(i, 10);
}
} );
download.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent( Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
intent.setType("image/*");
startActivityForResult( intent, gallery );
}
} );
}
} );
}
private void getFileUri() {
image_name = "testing123.jpg";
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
+ File.separator + image_name
);
file_uri = Uri.fromFile(file);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//code here
}
}
在这里我想将捕获的图像添加到我的数据库中,也是原始大小,而不是缩略图。
我还有一个关于 MySQL 的内容。我们可以将图像文件存储在数据库中吗?如果不是,那么它们如何存储图像。
还有关于如何将我捕获的图像存储在内部存储中的任何建议。
【问题讨论】:
标签: php android mysql android-image