TinyDB problem, cannot resolve symbol 'context'

39 views Asked by At

I want to use TinyDB in my Android app that built in Android Studio. To use the TinyDB, I need to add TinyDB class and write the context.

The context that need to be in the MainActivity: TinyDB tinydb = new TinyDB(context); And it shows "Cannot resolve symbol 'context'"

Context part in TinyDB class:

public TinyDB(Context appContext){
    preferences = PreferenceManager.getDefaultSharedPrefeences(appContext);
    context = appContext;
}

Should I replace 'context' with something else?

1

There are 1 answers

1
hata On BEST ANSWER

In Activity, the Context is Activity itself (=this):

TinyDB tinydb = new TinyDB(this);