Home » Android » What is meant by metadata in android?

What is meant by metadata in android?

Posted by: admin June 15, 2020 Leave a comment


When you start a drag, you include both the data you are moving and metadata describing this data as part of the call to the system,the following explanation was found in android developers site

here,What is meant by metadata in android?

How to&Answers:

From what I gather metadata is essentially a way to access properties. The following link provides an example with a brief explanation:

This field can be used to store a boolean, float, int, or String and is later accessed by the Bundle method for your data type (e.g., getInt()). Here is an example of how to define a value in your AndroidManifest.xml:

   <meta-data android:name="my_api_key" android:value="mykey123" /> 

The returned ApplicationInfo contains a field, metaData, which is actually a Bundle containing all the meta data. Line 4 fetches a String that is the same as the “android:name” parameter in the XML.

    ApplicationInfo ai = getPackageManager().getApplicationInfo(activity.getPackageName(), PackageManager.GET_META_DATA); 
    Bundle bundle = ai.metaData;   
    String myApiKey = bundle.getString("my_api_key");