开发者

getResources / OpenRawSource causing runtime exception

开发者 https://www.devze.com 2023-04-02 18:54 出处:网络
I want to read from a text file. In a Java app, this BufferedReader f = new BufferedReader(new FileReader(filename));

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 eithe开发者_运维技巧r.

What am I missing here?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消