Here is the code
public class RSSReader extends IntentService{
protected void onHandleIntent(Intent intent) {
try {
File myFile = new File(Environment.getExternalStorageDirectory()+"rss.txt");
FileInputStream fIn = new FileInputStream(myFile);
BufferedReader myReader = new BufferedReader(
new InputStreamReader(fIn));
String aDataRow = "";
String aBuffer = "";
result2 = myReader.readLine();
myReader.close();
Log.i(TAG,"File read.");
} catch (Exception e) {
...
}
if (...) {
sendNotification("There are new notices.");
Log.i(TAG, "New notice.");
result2 =result;
try {
File file = new File(Environment.getExternalStorageDirectory()+File.separator+"rss.txt");
file.mkdirs();
file.createNewFile();
FileOutputStream fOut = new FileOutputStream(file);
OutputStreamWriter myOutWriter =
new OutputStreamWriter(fOut);
myOutWriter.append(result2);
myOutWriter.close();
fOut.close();
Log.i(TAG,"File created");
}catch (Exception e){
...
}
}else{
...
}
SampleAlarmReceiver.completeWakefulIntent(intent);
}
...
}
This service is started by an AlarmManager. I am trying to create a file on SDcard and read it when the AlarmManager triggers the second time. Is this even possible? Right now I am getting an error saying "open failed: Permission Denied : EACCES" Can someone help me out? Thank you.