I am writting a program in which user can select one of the text files in the sdcard. I am using this code to give the user access to sdcard:

in oncreate method:

            Intent intent = new Intent();
            intent.setType("*/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "getFile"),
                    22);

But, I can not access the sdcard. can anybody please help me? p.s i don't want to use any external library like fileChooser or etc.

有帮助吗?

解决方案

You need add a READ_EXTERNAL_STORAGE permission in your AndroidManifest.xml file:

http://developer.android.com/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top