I use ContentProvider but sometimes I get the message written in the title. What is the reason? I read that this message would appear if I closed a database before closing a cursor. I also read that I shouldn't take care of closing the cursor if I use ContentProvider 
            Asked
            
        
        
            Active
            
        
            Viewed 2,873 times
        
    3
            
            
         
    
    
        Community
        
- 1
- 1
 
    
    
        Maksim Dmitriev
        
- 5,985
- 12
- 73
- 138
2 Answers
5
            It's true that you don't have to close the database when using ContentProvider, but this doesn't apply for cursors. You must be using getContentResolver().query() which returns a cursor. Eventually you will have to close that returned cursor with .close(), otherwise you'll get that nasty message.
 
    
    
        Csongor Kiss
        
- 715
- 6
- 11
0
            
            
        Use Code like following to run in strict mode
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
             .detectDiskReads()
             .detectDiskWrites()
             .detectNetwork()   // or .detectAll() for all detectable problems
             .penaltyLog()
             .build());
     StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
             .detectLeakedSqlLiteObjects()
             .detectLeakedClosableObjects()
             .penaltyLog()
             .penaltyDeath()
             .build());
This starts producing on closable things etc. Hence helps in debugging where the error arose from.
Source : https://developer.android.com/reference/android/os/StrictMode.html
 
    
    
        ShReYaNsH
        
- 302
- 2
- 10