I have been trying to work around this for several hours and I am extremely frustrated so I am coming to you guys for some guidance.
I am trying to save and retriev
This java.io.FileNotFoundException: /storage/emulated/0myFile.ser
looks like you are missing a '/' in the path.
Use
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + '/';
Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running
Everything you need to know is in :
https://developer.android.com/training/permissions/requesting.html
The other error has nothing to do with it
You've added the permission in manifest, So I'm sure you are not asking runtime permissions. If you are using SDK 23 or higher, Ask runtime permission. For reference I'm adding some snippet here:
if(Build.VERSION.SDK_INT>22){
requestPermissions(new String[] {YOUR_PERMISSIONS AS STRING}, 1);
}
and to check whether permission is granted or not, you need to use onRequestPermissionResults()
method.
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 1: {
if (!(grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED)) {
Toast.makeText(addAlarm.this, "Permission denied to access your location.", Toast.LENGTH_SHORT).show();
}
}
}
}