Я использую этот код для выбора файла в браузере файлов в своем приложении для Android:
activityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> {
if(result.getResultCode() == RESULT_OK && result != null)
{
profileAddIV.setEnabled(false);
progressBarProfileImage.setVisibility(View.VISIBLE);
ExecutorService executor = Executors.newSingleThreadExecutor();
Handler handler = new Handler(Looper.getMainLooper());
executor.execute(() -> {
boolean hasError;
Uri uploadfileuri = result.getData().getData();
InputStream inputStream = null;//You can get an inputStream using any IO API
File file = new File(result.getData().toString());
int fileSize = (int) file.length();
}
});
}
});
Подробнее здесь: https://stackoverflow.com/questions/798 ... om-the-fil