0

I want to read from a text file. In a Java app, this

BufferedReader f = new BufferedReader(new FileReader(filename));

works, in Android I tried

BufferedReader f = new BufferedReader (new InputStreamReader(getResources().openRawResource(R.raw.autobahnnetz_gps))) ;

which crashes the app. If I use this in the main activity class, it works fine. So I guess I have to pass the context to getResources by

getApplicationContext().getResources

but that doesnt work either.

What am I missing here?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
fweigl
  • 21,278
  • 20
  • 114
  • 205
  • Hrmmm... do you have any logcat output or any exception messages coming out? Can you post the class where you are using this code? – Adrian Rodriguez Sep 03 '11 at 03:13
  • This is the class:http://pastebin.com/KirDVRSe – fweigl Sep 03 '11 at 04:14
  • This is the class:http://pastebin.com/KirDVRSe The Logcat doesnt give any errors, this is all I got: ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1816 e NullPointerException (id=830007996248) cause NullPointerException (id=830007996248) detailMessage null stackState (id=830007996280) stackTrace null – fweigl Sep 03 '11 at 04:21

1 Answers1

0

ya this problem is exist, but i am able to find one work around see this

Community
  • 1
  • 1
Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115