I'd like to get a context from Fragment. I tried getApplicationContext()
and FragmentClass.this
to get a context from the database creator, but it didn't work. What should I do?
public Database(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}
This is my code.
android android-fragments android-context
If you use getActivity()
in Fragment, you can get activities This activity is Context.
© 2024 OneMinuteCode. All rights reserved.