共用方式為


WebView.SetDataDirectorySuffix(String) Method

Definition

Define the directory used to store WebView data for the current process.

[Android.Runtime.Register("setDataDirectorySuffix", "(Ljava/lang/String;)V", "", ApiSince=28)]
public static void SetDataDirectorySuffix (string suffix);
[<Android.Runtime.Register("setDataDirectorySuffix", "(Ljava/lang/String;)V", "", ApiSince=28)>]
static member SetDataDirectorySuffix : string -> unit

Parameters

suffix
String

The directory name suffix to be used for the current process. Must not contain a path separator.

Attributes

Remarks

Define the directory used to store WebView data for the current process. The provided suffix will be used when constructing data and cache directory paths. If this API is not called, no suffix will be used. Each directory can be used by only one process in the application. If more than one process in an app wishes to use WebView, only one process can use the default directory, and other processes must call this API to define a unique suffix.

This means that different processes in the same application cannot directly share WebView-related data, since the data directories must be distinct. Applications that use this API may have to explicitly pass data between processes. For example, login cookies may have to be copied from one process's cookie jar to the other using CookieManager if both processes' WebViews are intended to be logged in.

Most applications should simply ensure that all components of the app that rely on WebView are in the same process, to avoid needing multiple data directories. The #disableWebView method can be used to ensure that the other processes do not use WebView by accident in this case.

This API must be called before any instances of WebView are created in this process and before any other methods in the android.webkit package are called by this process.

Java documentation for android.webkit.WebView.setDataDirectorySuffix(java.lang.String).

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