Search code examples
javaandroidandroid-intentandroid-intentserviceandroid-storage

Open File-Intent in all devices through the same code or by applying any logic


I want to choose a file via an Android File Manager.

so, to open file intent code is

Intent intent = new Intent();
intent.setType("file/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select File"), 1);

But I was unable to access file manager in samsung devices to resolve this problem i do

Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
intent.putExtra("CONTENT_TYPE", "*/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, 1);  

But this code in not working in other devices so what should i do to open file manager in all devices ?


Solution

  • private void openFile(int  requestCODE) {
        Intent i = new Intent(Intent.ACTION_GET_CONTENT);
        i.setType("*/*");
        startActivityForResult(intent, requestCODE);
    }