Partager via


ContentProvider.Shutdown Method

Definition

Implement this to shut down the ContentProvider instance.

[Android.Runtime.Register("shutdown", "()V", "GetShutdownHandler")]
public virtual void Shutdown ();
[<Android.Runtime.Register("shutdown", "()V", "GetShutdownHandler")>]
abstract member Shutdown : unit -> unit
override this.Shutdown : unit -> unit
Attributes

Remarks

Implement this to shut down the ContentProvider instance. You can then invoke this method in unit tests.

Android normally handles ContentProvider startup and shutdown automatically. You do not need to start up or shut down a ContentProvider. When you invoke a test method on a ContentProvider, however, a ContentProvider instance is started and keeps running after the test finishes, even if a succeeding test instantiates another ContentProvider. A conflict develops because the two instances are usually running against the same underlying data source (for example, an sqlite database).

Implementing shutDown() avoids this conflict by providing a way to terminate the ContentProvider. This method can also prevent memory leaks from multiple instantiations of the ContentProvider, and it can ensure unit test isolation by allowing you to completely clean up the test fixture before moving on to the next test.

Java documentation for android.content.ContentProvider.shutdown().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to