1

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.

Stacks13
  • 40
  • 5
  • Possible duplicate of : http://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android – Bubu Oct 29 '15 at 20:56
  • There are no errors in the manifest. Yet, I am facing this problem. Is it because I am creating a file in a service? Thank you for the early reply. – Stacks13 Oct 29 '15 at 21:05

0 Answers0