I have this code:
protected void pickFile(View view){
///Codigo que abre la galeria de imagenes y carga la imagen en displayedImage
Intent intent = new Intent();
intent.setType("file/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Choose File to Upload"), 1);
}
//It's executed when leaving file system
@Override
protected void onActivityResult(int reqCode, int resCode, Intent data){
super.onActivityResult(reqCode, resCode, data);
if (reqCode == 1 && resCode == RESULT_OK && data != null) {
Uri selectedFile = data.getData();
RequestMaker.uploadFile(this, selectedFile, "this is a file");
}
}
What i want to do is to be able to select any file from my phone and send it.
The code works, it opens the chooser and lets me search for any file. However, there are a few problems i am having:
- When i try to access via "Internal Storage" option, i cannot select any item. They are all disabled. I fixed that installing a file manager and it lets me choose the files i want, but maybe there is a quick fix for that.
- When i select the file and run Uri.getPath(), sometimes the path is valid, others, and in general when i am selecting some image file, there is an error with the path i get in return. Is not the actual one. I saw some fixes online but they are all for selecting images from the galery, i want the general one.
How can i fix this?