How to query SQLlite From Helper Class With No Context

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 6

Jul 19, 2018, 5:56:38 PM via Website

In order to make my database call to my provider class, I need to specify a ContentResolver to use, and this is derived from the context as follows:

                    final ContentResolver contentResolver = getContext().getContentResolver();

The problem is this class is strictly a data model with getters and setters for building an object. I want to make a call to the database in this class, in order to partially populate this model but in order to do so, this model requires a context. Since it has no associated activity, it doesn't really have a context. How is this achieved from classes without an activity?

Be the first to answer

Recommended articles