I want to ask why we get this annotation:
Method invocation getContext.getContentResolver() may produce NullPointerException
Why i
According to ContentProvider getContext() docs:
Retrieves the Context this provider is running in. Only available once onCreate() has been called -- this will return null in the constructor.
So the getContext()
method does not return null
in insert()
, update()
or delete()
, because onCreate()
will be called before these calls.
So it's OK to disable that warning for that line if you use it in such case...
//noinspection ConstantConditions
getContext().getContentResolver().notifyChange(uri, null);