I am new to Android development.
I need to read a text file from the SD card and display that text file. Is there any way to view a text file directly in Android or
You should have READ_EXTERNAL_STORAGE permission for reading sdcard. Add permission in manifest.xml
From android 6.0 or higher, your app must ask user to grant the dangerous permissions at runtime. Please refer this link Permissions overview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
}
}