Stay organized with collections
Save and categorize content based on your preferences.
Retention
@Target([AnnotationTarget.ANNOTATION_CLASS]) class Retention
Indicates how long annotations with the annotated interface are to be retained. If no Retention annotation is present on an annotation interface declaration, the retention policy defaults to RetentionPolicy.CLASS
.
A Retention meta-annotation has effect only if the meta-annotated interface is used directly for annotation. It has no effect if the meta-annotated interface is used as a member interface in another annotation interface.
Summary
Public constructors |
Indicates how long annotations with the annotated interface are to be retained.
|
Public constructors
Retention
Retention(value: RetentionPolicy)
Indicates how long annotations with the annotated interface are to be retained. If no Retention annotation is present on an annotation interface declaration, the retention policy defaults to RetentionPolicy.CLASS
.
A Retention meta-annotation has effect only if the meta-annotated interface is used directly for annotation. It has no effect if the meta-annotated interface is used as a member interface in another annotation interface.
Properties
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Retention\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nRetention\n=========\n\n```\n@Target([AnnotationTarget.ANNOTATION_CLASS]) class Retention\n```\n\n|-------------------------------------|\n| [java.lang.annotation.Retention](#) |\n\nIndicates how long annotations with the annotated interface are to be retained. If no Retention annotation is present on an annotation interface declaration, the retention policy defaults to `RetentionPolicy.CLASS`.\n\nA Retention meta-annotation has effect only if the meta-annotated interface is used directly for annotation. It has no effect if the meta-annotated interface is used as a member interface in another annotation interface.\n\nSummary\n-------\n\n| Public constructors ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Retention](#Retention(java.lang.annotation.RetentionPolicy))`(`value:` `[RetentionPolicy](/reference/kotlin/java/lang/annotation/RetentionPolicy)`)` Indicates how long annotations with the annotated interface are to be retained. |\n\n| Properties ||\n|---------------------------------------------------------------------------|------------------------------------------------------------------------------------|\n| [RetentionPolicy](/reference/kotlin/java/lang/annotation/RetentionPolicy) | [value](#value:java.lang.annotation.RetentionPolicy) Returns the retention policy. |\n\nPublic constructors\n-------------------\n\n### Retention\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nRetention(value: RetentionPolicy)\n```\n\nIndicates how long annotations with the annotated interface are to be retained. If no Retention annotation is present on an annotation interface declaration, the retention policy defaults to `RetentionPolicy.CLASS`.\n\nA Retention meta-annotation has effect only if the meta-annotated interface is used directly for annotation. It has no effect if the meta-annotated interface is used as a member interface in another annotation interface.\n\nProperties\n----------\n\n### value\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval value: RetentionPolicy\n```\n\nReturns the retention policy.\n\n| Return ||\n|---------------------------------------------------------------------------|----------------------|\n| [RetentionPolicy](/reference/kotlin/java/lang/annotation/RetentionPolicy) | the retention policy |"]]