So my problem is that I need pick image from gallery and then move him into my file and then save this path(path to my file) in string. Is it possible to do such thing? I'm beginner and really need this. This is my code which works on same issue but with camera.
private void openGallery(){
Intent vyber = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.INTERNAL_CONTENT_URI);
File file2 = getFile2();
vyber.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(file2));
startActivityForResult(vyber , PICK_IMAGE);
}
}
private File getFile2()
{
File folder = new File("sdcard/MyDirectory");
if (!folder.exists())
{
folder.mkdir();
}
File image_file2 = new File(folder,kod_useku_komunikaceS+"_gallery_image.jpg");
return image_file2;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if (resultCode == RESULT_OK && requestCode == PICK_IMAGE){
String cesta = "sdcard/MyDirectory/"+kod_useku_komunikaceS+"_gallery_image.jpg";
path_gallery = cesta;
imageView_VyberFotku.setImageDrawable(Drawable.createFromPath(cesta));