I'm attempting to read a txt file I have in my project. I keep getting the exception FileNotFound and have no idea why. The file is in the project folder under the AnroidManifest XML, but yet it is great at hiding from me anyway. Please help because I am about to go crazy getting frustrated with this. I know I can use Raw and Assets to read txt files, but I need to be able to write to this txt file as well as read it.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FileInputStream getIn;
try {
getIn = openFileInput("filenames.txt");
//Creating an InputStreamReader and setting my FileInputStream
InputStreamReader read = new InputStreamReader(getIn);
//Creating a new BufferReader and adding the InputStreamReader
BufferedReader dis = new BufferedReader(read);
Toast.makeText(getApplicationContext(), dis.readLine(), Toast.LENGTH_SHORT).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}