Read File With Android, What Is The Expected Path?
I am not having luck with this method, which is basically a hello world for printing file contents to the Android cat log. try { InputStream instream = openFileInput(
Solution 1:
This will try to read the file inputFile.txt
from your internal application data directory /data/data/your.application.package/
(and will fail if it doesn't exist):
openFileInput("inputFile.txt");
To read a file from SD card you would do something like this:
new FileInputStream(Environement.getExternalStorageDirectory()
.getAbsolutePath() + "/inputFile.txt")
Don't forget to set the SD card permission in your manifest then:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Solution 2:
This file should exist in the apps local 'data' directory. Does this file already exist? Have you taken a look at the documentation for file IO on Android?
Post a Comment for "Read File With Android, What Is The Expected Path?"