I am having no end of trouble accessing a file that I know exists for using it in a BufferedReader. Here's the code:
File file = new File(Environment.DIRECTORY_DOWNLOADS + getString(R.string.dloaded_latest_numbers_dir) + getString(R.string.dloaded_latest_numbers_file));
BufferedReader buffedReader = new BufferedReader(new FileReader(file));
But every time I hit the BufferedReader line I get "java.io.FileNotFoundException: /Download/MyDir/MyFile.txt: open failed: ENOENT (No such file or directory)"
I am displaying the file location in a TextView with:
TextView displayFileLocation = (TextView) findViewById(R.id.readLocTextView);
displayFileLocation.setText("location is: " + file.getAbsolutePath());
Which displays the correct full path to the file. (/Download/MyDir/MyFile.txt)
My AndroidManifest.xml file has the following permissions:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
logcat output is:
07-08 13:06:28.556 15351-15351/au.com.acent.ash.basiclottochecker D/OpenGLRenderer﹕ Enabling debug mode 0
07-08 13:06:43.451 15351-15351/au.com.acent.ash.basiclottochecker W/IInputConnectionWrapper﹕ showStatusIcon on inactive InputConnection
07-08 13:06:57.925 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ java.io.FileNotFoundException: /Download/MyDir/MyFile.txt: open failed: ENOENT (No such file or directory)
07-08 13:06:57.925 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:420)
07-08 13:06:57.925 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.io.FileInputStream.<init>(FileInputStream.java:78)
07-08 13:06:57.925 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.io.FileReader.<init>(FileReader.java:42)
07-08 13:06:57.925 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at au.com.acent.ash.basiclottochecker.CheckerActivity.populateButton(CheckerActivity.java:64)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:525)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.view.View$1.onClick(View.java:3809)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.view.View.performClick(View.java:4421)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.view.View$PerformClick.run(View.java:17903)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:730)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:92)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.os.Looper.loop(Looper.java:213)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5225)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:525)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at libcore.io.Posix.open(Native Method)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:404)
07-08 13:06:57.935 15351-15351/au.com.acent.ash.basiclottochecker W/System.err﹕ ... 17 more
I am absolutely positive this file exists and I have used DownloadManager to download this file to the exact same place using the exact same location reference for the directory location:
File file = new File(Environment.DIRECTORY_DOWNLOADS + getString(R.string.dloaded_latest_numbers_dir));
What am I doing wrong?? Please help!