kony.ds Namespace
The kony.ds namespace provides data storage functionality. It contains the following API elements.
Functions
The kony.ds namespace contains the following functions.
This API provides you an ability to read the data stored on the data store of the mobile device using the given name identifier. A reference to the data table is returned.
Use Cases
You can use this API when you want to:
- fetch the data stored on the mobile device and re-use it.
- know the data associated with a name identifier before you delete it.
Syntax
kony.ds.read(name,storeContext);
Input Parameters
Parameter | Description |
---|---|
name [String] - Mandatory | Specifies the unique name identifier that represents the data on the data store |
storeContext [String] - Optional |
Specifies the unique identifier that of the data store if the data store is shared between apps. The storeContext parameter is a dictionary that holds the following keys.
|
Example
kony.ds.read("friends");
Return Values
Return Value | Description |
---|---|
Reference [String] | A reference to the table is returned |
nil [nil] | nil is returned if no record is found |
Error Codes
The following error codes are returned:
- 704 Unknown error
- 705 Invalid parameters
- 706 Invalid parameter type. A non-string type specified as the name of the datastore
Implementation Details
If you use secure=true, while saving the data in ds.save, then the ds.read API fetches the correct values only if you are invoking the API on a form enabled for Secure Submit. Else, it will return nil.
Platform Availability
Available on all platforms.
This API allows you to delete the data stored on the data store that corresponds to a specific name identifier.
Syntax
kony.ds.remove (name, storeContext);
Input Parameters
Parameter | Description |
---|---|
name [String] - Mandatory | Specifies the name identifier using which the table was saved. |
storeContext [String] - Optional |
Specifies the unique identifier that of the data store if the data store is shared between apps. The storeContext parameter is a dictionary that holds the following keys.
|
Example
kony.ds.remove("friends");
Return Values
Return Value | Description |
---|---|
status [Boolean] |
true - if the table is deleted successfully false - if the table is not deleted, or if no datastore exists with the key specified |
Platform Availability
Available on all platforms.
This API allows you to save the given data using the specified name identifier in the data store of the mobile device.
Use Cases
You can use this API to store data on the mobile device that you may require even after quitting the application.
Syntax
kony.ds.save(inputtable, name, metainfo, storeContext);
Input Parameters
Parameter | Description |
---|---|
inputtable [Array] - Mandatory | Specifies the table that needs to be saved (array of values) |
name [String] - Mandatory | Specifies the name identifier for the table. The data is stored on the data store with this name identifier. You must use this identifier if you want to retrieve data from the data store. |
metainfo [Table] - Optional |
Specifies a table with key-value pairs. You have an option to store the data in the user session or cache or create a cookie to be placed on the device.
The following points are applicable only to metainfo [Table] parameter:
You should provide a key value in the metainfo as key: "dsmode" value:"cache/session/cookie"
Based on the mode you specify here, the availability of the data after you quit the application varies. For example, |
storeContext [String] - Optional |
Specifies the unique identifier that of the data store if the data store is shared between apps. The storeContext parameter is a dictionary that holds the following keys.
|
Example
kony.ds.save(["John","Joe","Jack"],"friends",{dsmode:"session"});
Return Values
None.
Error Codes
The following error codes are returned:
- 700 Unknown error
- 701 Invalid parameters specified
- 702 Invalid parameter type.
- 703 Invalid parameter type. A non-string type specified as input
- 704 Unknown error
- 705 Invalid parameters
- 706 Invalid parameter type. A non-string type specified as the name of the datastore
Implementation Details
If you save some other data on the data store with the same name identifier used earlier, data is overridden.
API Usage
We recommend you not to store save sensitive data like passwords, account numbers, and so on using this API.
Platform Availability
Available on all platforms.