cordova-plugin-camera icon indicating copy to clipboard operation
cordova-plugin-camera copied to clipboard

fix(android): close cursors to suppress log warnings

Open manstie opened this issue 4 years ago • 0 comments

Platforms affected

Android

Motivation and Context

  • "W/System: A resource failed to call close" is logged whenever a Cursor object is left unclosed in this file.
  • android.content.ContentResolver.query returns:
A Cursor object, which is positioned before the first entry. May return null if the underlying content provider returns null, or if it crashes.

So we should check for null Cursors after running queryImgDB

Description

  • Added null checks before running functions on Cursor objects.
  • Close all cursor objects after they have been created and used.

Testing

I ran an app using this plugin in debug mode through Android Studio and confirmed the warnings no longer appear after these changes have been made.

manstie avatar Nov 09 '21 02:11 manstie