I am trying to open a file which is in the assets folder. But using getAssets() gives the error given above. I know I have to pass the context from another activity, but I can't do that either as then another error comes-"The method onCreate(SQLiteDatabase, Context) of type ClassName must override or implement a supertype method". So I am stuck. Is there a better way of opening that file? Here is the line:
InputStream is = getAssets().open("file1.txt"); *Note: ClassName is not an activity, it's just a class, so getAssets() cannot work without passing context from another activity.
Edit: Here is the class and onCreate declaration:
public class DatabaseHandler extends SQLiteOpenHelper { @Override public void onCreate(SQLiteDatabase db) {//some stuff InputStream is = getAssets().open("file1.txt"); //more stuff } }