GenericDocument.GetProperty(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves the property value with the given path as Object
.
[Android.Runtime.Register("getProperty", "(Ljava/lang/String;)Ljava/lang/Object;", "GetGetProperty_Ljava_lang_String_Handler", ApiSince=31)]
public virtual Java.Lang.Object? GetProperty (string path);
[<Android.Runtime.Register("getProperty", "(Ljava/lang/String;)Ljava/lang/Object;", "GetGetProperty_Ljava_lang_String_Handler", ApiSince=31)>]
abstract member GetProperty : string -> Java.Lang.Object
override this.GetProperty : string -> Java.Lang.Object
Parameters
- path
- String
The path to look for.
Returns
The entry with the given path as an object or null
if there is no such path.
The returned object will be one of the following types: String[]
, long[]
,
double[]
, boolean[]
, byte[][]
, GenericDocument[]
.
- Attributes
Remarks
Retrieves the property value with the given path as Object
.
A path can be a simple property name, such as those returned by #getPropertyNames
. It may also be a dot-delimited path through the nested document hierarchy, with nested GenericDocument
properties accessed via '.'
and repeated properties optionally indexed into via [n]
.
For example, given the following GenericDocument
:
(Message) {
from: "sender@example.com"
to: [{
name: "Albert Einstein"
email: "einstein@example.com"
}, {
name: "Marie Curie"
email: "curie@example.com"
}]
tags: ["important", "inbox"]
subject: "Hello"
}
Here are some example paths and their results:
<ul> <li>"from"
returns "sender@example.com"
as a String
array with one element <li>"to"
returns the two nested documents containing contact information as a GenericDocument
array with two elements <li>"to[1]"
returns the second nested document containing Marie Curie's contact information as a GenericDocument
array with one element <li>"to[1].email"
returns "curie@example.com"
<li>"to[100].email"
returns null
as this particular document does not have that many elements in its "to"
array. <li>"to.email"
aggregates emails across all nested documents that have them, returning ["einstein@example.com", "curie@example.com"]
as a String
array with two elements. </ul>
If you know the expected type of the property you are retrieving, it is recommended to use one of the typed versions of this method instead, such as #getPropertyString
or #getPropertyStringArray
.
If the property was assigned as an empty array using one of the Builder#setProperty
functions, this method will return an empty array. If no such property exists at all, this method returns null
.
Note: If the property is an empty GenericDocument
[] or byte[][]
, this method will return a null
value in versions of Android prior to android.os.Build.VERSION_CODES#TIRAMISU Android T
. Starting in Android T it will return an empty array if the property has been set as an empty array, matching the behavior of other property types.
Java documentation for android.app.appsearch.GenericDocument.getProperty(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.