0
为什么我们使用restartLoader(),如果loader已经隐含地监听数据库中的任何更新?我们是否使用它来重复使用相同的装载器来发送不同的查询?为什么要使用restartLoader()?
为什么我们使用restartLoader(),如果loader已经隐含地监听数据库中的任何更新?我们是否使用它来重复使用相同的装载器来发送不同的查询?为什么要使用restartLoader()?
因为有时您可能想要更改您的查询中的where条件。您可以调用restartLoader并在Bundle参数中传递where条件。 restartLoader将再次调用initLoader并使用new where条件创建一个新的cursorloader。如果您不调用restartLoader,则无法更改查询中的where条件。
另外restartCursorLoader会再次执行查询,从而刷新UI。您永远不需要使用ContentResolver进行查询。只需调用restartCursorLoader并进行查询即可。 –