Thao tác này sẽ mở trình khám phá tệp tích hợp nếu có, nếu không sẽ yêu cầu bạn chọn trình khám phá tệp mà bạn đã cài đặt.
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
//intent.setType("*/*"); //all files
intent.setType("text/xml"); //XML file only
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show();
}
}
Nguồn
2015-12-10 16:31:10
lần chủ đề này, http://stackoverflow.com/questions/5537907/view -file-path-in-a-file-manager-as-android-intent Nếu tôi không sai. Điều này có thể giúp bạn. –