before Intent intent; intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("text/plain"); // MIME type for text files intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, READ_REQUEST_CODE); after : define resultLauncher and start ActivityResultLauncher mGetContent = registerForActivityResult(new ActivityResultContracts...