Answer the question
In order to leave comments, you need to log in
How to make file explorer on android?
Need to be able to load a .png image in a game made with Unity for later use. In this case, the target path is initially unknown, and the user must find the file on their own.
It is also known that root folders have different names for different devices.
Answer the question
In order to leave comments, you need to log in
If it's simple, then something like this:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);
int permissionStatus = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE);
if (permissionStatus == PackageManager.PERMISSION_GRANTED) {
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 2);
} else {
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE); // call onRequestPermissionsResult to select file from gallery
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question