【发布时间】:2012-01-14 22:43:17
【问题描述】:
我正在尝试创建自己的类来从文件中读取行,但这似乎是问题所在。
据我所知,标准 (Java) 方法在 Android 下不起作用。我需要 getResources() 等等。
public myInput(Context context) throws FileNotFoundException{
super();
br = new BufferedReader(new InputStreamReader(context.getResources().
openRawResource(R.raw.file)));
}
这就是构造函数。我正在尝试像这样创建它。
public void choosePassword(Context context){
try{
myInput fromFile = new myInput(context);
} catch(Exception e){
}
}
方法choosePassoword() 是从我的Activity 类中调用的,老实说不知道他想要什么上下文。我想为方法 choosePassword() 提供他应该从中选择密码的文件,这就是我想要的...有人可以帮我这样做吗?
【问题讨论】:
标签: android file class readline android-context