Restarting CursorLoader does not reflect database deletion

I use CursorLoader to track data in a database. This database can be deleted using

Context.deleteDatabase(databaseName); 

After uninstalling, I reboot the bootloader with

 getLoaderManager().restartLoader(LOADER_ID, null, this); 

Now when i get the callback

 onLoadFinished(Loader<Cursor> loader, Cursor data) 

it does not reflect that the data has disappeared. I get the same data as before.

Am I doing something conceptually wrong?

+4
source share
1 answer

LoaderManager tries to be smart and reuse the bootloader. This is a workaround for another bootloader error, but I think this will work for this:

  Loader<Object> loader = getLoaderManager().getLoader(0); if (loader != null && ! loader.isReset()) { getLoaderManager().restartLoader(0, null, mItemsListener); } else { getLoaderManager().initLoader(0, null, mItemsListener); } 
+2
source

Source: https://habr.com/ru/post/1415971/


All Articles