Share via


ClassLoader.GetResource(String) Method

Definition

Finds the resource with the given name.

[Android.Runtime.Register("getResource", "(Ljava/lang/String;)Ljava/net/URL;", "GetGetResource_Ljava_lang_String_Handler")]
public virtual Java.Net.URL? GetResource (string? name);
[<Android.Runtime.Register("getResource", "(Ljava/lang/String;)Ljava/net/URL;", "GetGetResource_Ljava_lang_String_Handler")>]
abstract member GetResource : string -> Java.Net.URL
override this.GetResource : string -> Java.Net.URL

Parameters

name
String

The resource name

Returns

URL

A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.

Attributes

Remarks

Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a '/'-separated path name that identifies the resource.

This method will first search the parent class loader for the resource; if the parent is null the path of the class loader built-in to the virtual machine is searched. That failing, this method will invoke #findResource(String) to find the resource.

Added in 1.1.

Java documentation for java.lang.ClassLoader.getResource(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

See also