I have to read a file called hello.txt using the following code on java/eclipse/android:
import java.io.InputStream;
public class Tokenirzer {
public String ReadPath () {
InputStream inputStream = getResources().openRawResource(R.raw.hello);
}
}
However I get the following error:
The method getResources() is undefined for the type Tokenirzer
What am I doing wrong?
getResources()is part ofContext. You can use it like that in anActivitybecause it inherits fromContext. You need to pass in your activity’s Context to usegetResources.