Sample Code Snippets - Android SDK | Zoho Creator Help

Sample code snippets

Note: Zoho Creator's Mobile SDK is currently a Beta feature. We do not recommend using it for apps in the production stage.

Java

Below are the code snippets that demonstrate how to use the different methods of Zoho Creator's SDK for Android:

To fetch the sections present in a Creator app

In the below snippet, Zylker_Orders is the target Creator application's link name:
  1. try {
  2. // your code goes here

  3.      ZCApplication firstApp = appList.get(0);
  4.      List<ZCSection> sections =
  5.      ZOHOCreatorUtil.getApplicationDetails(firstApp);
  6.  } catch (ZCException e) {
  7.          e.printStackTrace();
  8.          // Handle Error
  9.  }

To fetch a form's meta information

In the below snippet, Orders is the target form's link name:
  1. try {
  2.     ... // your code goes here
  3.     ZCSection firstSection = sections.get(0);
  4.     ZCComponent firstComponent =
  5.     firstSection.getComponents().get(0);
  6.     if(firstComponent.getType().equals(ZCComponentType.FORM)){
  7.         ZCForm form = FormUtil.getForm(firstComponent);
  8.     }
  9. } catch (ZCException e) {
  10.     e.printStackTrace();
  11.     // Handle Error
  12. }

To fetch a report's meta information

In the below snippet, All_Orders is the target report's report name:
  1. try {
  2.     ... // your code goes here
  3.     ZCSection firstSection = sections.get(0);
  4.     ZCComponent firstComponent =
  5.     firstSection.getComponents().get(0);
  6.     if(firstComponent.getType().equals(ZCComponentType.REPORT)){
  7.         ZCReport report = ReportUtil.getReport(firstComponent);
  8.     }
  9. } catch (ZCException e) {
  10.     e.printStackTrace();
  11.     // Handle Error
  12. } catch (CloneNotSupportedException e) {
  13.     e.printStackTrace();
  14. }

Kotlin

To fetch the sections present in a Creator app

In the below snippet, Zylker_Orders is the target Creator application's link name:
  1. try {
  2.     ... // your code goes here
  3.     val firstApp: ZCApplication = appList.get(0)
  4.     val sections: List = ZOHOCreatorUtil.getApplicationDetails(firstApp)
  5. } catch (e: ZCException) {
  6.     e.printStackTrace()
  7.     // Handle Error
  8. }

To fetch a form's meta information

In the below snippet, Orders is the target form's link name:
  1. try {
  2.     ... // your code goes here
  3.     val firstSection: ZCSection = sections.get(0)
  4.     val firstComponent = firstSection.components.get(0)
  5.     if (firstComponent.type == ZCComponentType.FORM) {
  6.         val form: ZCForm = FormUtil.getForm(firstComponent)
  7.     }
  8. } catch (e: ZCException) {
  9.     e.printStackTrace()
  10.     // Handle Error
  11. }

To fetch a report's meta information

In the below snippet, All_Orders is the target report's report name:
  1. try {
  2.     ... // your code goes here
  3.     val firstSection: ZCSection = sections.get(0)
  4.     val firstComponent = firstSection.components[0]
  5.     if (firstComponent.type == ZCComponentType.REPORT) {
  6.         val report = ReportUtil.getReport(firstComponent, 50)
  7.     }
  8. } catch (e: ZCException) {
  9.     e.printStackTrace()
  10.     // Handle Error
  11. } catch (e: CloneNotSupportedException) {
  12.     e.printStackTrace()
  13. }