Problems writing to a file in Android?  This is from Holden Hernandez Carmenate, a CS6326 student:

The app does not ask for permissions if the API is greater than 22 (our app was developed using Marshmallow API 23, an unfortunate coincidence.)

 

The error was fixed in the device, going to:

Settings / Application Manager / <our application name> / Permission and activating a switch called storage !

 

I fixed it in code including the following two lines in onCreate:

if(ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)

                requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);

 

 The app now asks for permission the first time at run time!