providerId: A provider ID to use, which should be shared between the DataControl provider and DataControl consumer.
dataId: A string for identifying specific data.
type: The DataType to use.
Return value:
DataControlConsumerObject The local DataControlConsumerObject.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the parameter type is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
//The data provider, a native application, should be pre-installed and launched.
//The same provider ID should be defined for the use of this API between a native application(provider) and a web application(consumer).
//In this example, the DictionaryDataControlProvider native sample application is used as a data control provider.
//Gets SQL type DataControlConsumerObject
try {
var globalSQLConsumer = tizen.datacontrol.getDataControlConsumer(
"http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "SQL");
} catch (err) {
console.log (err.name +": " + err.message);
}
// Gets MAP type DataControlConsumerObject
try {
globalMappedConsumer = tizen.datacontrol.getDataControlConsumer(
"http://tizen.org/datacontrol/provider/DictionaryDataControlProvider", "Dictionary", "MAP");
} catch (err) {
console.log (err.name +": " + err.message);
}
2.3. DataControlConsumerObject
This interface provides common attributes for other derived DataControlConsumerObject.
An attribute to hold a provider identifier of the application with whom it shares the DataControl. This attribute should be known to users who want to interact with the application.
Since 2.4
readonly DOMString dataId
The dataId identifies specific data, usually a database table to process(insert, delete, update). The string consists of one or more components, separated by a slash('/').
Since 2.4
Methods
addChangeListener
Adds a listener to receive notifications about provider data changes.
Remark : To monitor DataControl provider data changes, it is not enough to implement a listener in the DataControl consumer. You also need to implement the data change sending functionality in the DataControl provider. The data sending implementation determines the actual change data returned to the DataControl consumer. For more information on the DataControl provider implementation, see Monitoring Data Changes.
Parameters:
dataChangeCallback: Callback method to be invoked when received data changed notification from provider application.
errorCallback [optional][nullable]: Callback method to be invoked if provider changes cannot be watched.
Return value:
long An identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type ServiceNotAvailableError, if the application could not connect with the provider.
Code example:
var watcherId = 0;
function dataChangeSuccessCallback(eventType, rowData)
{
console.log("Operation " + eventType + " was performed");
console.log("Data changed:");
for (var i = 0; i < rowData.columns.length; i++)
{
console.log("column " + rowData.columns[i] + " value " + rowData.values[i]);
}
}
function errorCallback(error)
{
console.log("The following error occurred: " + error.name);
}
try
{
var rowData =
{
columns : ["WORD", "WORD_DESC"] ,
values : ["'tizen1'", "'tizen2'"]
};
watcherId = globalSQLConsumer.addChangeListener(dataChangeSuccessCallback, errorCallback);
console.log("Change listener has been added with watchId = " + watcherId);
/* Define globalReqId before */
/* Increases globalReqId for uniqueness */
globalReqId++;
globalSQLConsumer.insert(globalReqId, rowData);
}
catch (err)
{
console.log(err.name + ": " + err.message);
}
Output example:
Change listener has been added with watchId = 1
Operation SQL_INSERT was performed
Data changed:
column WORD value 'tizen1'
column WORD_DESC value 'tizen2'
removeChangeListener
Removes data change listener.
void removeChangeListener(long watchId);
Since: 4.0
If the watchId argument is valid and corresponds to a subscription already in place, the watch process must immediately stop and no further callbacks must be invoked. If the watchId argument is not valid or does not correspond to a valid subscription, the method should return without any further action.
reqId: A unique identifier for the current operation.
So a developer should increase the reqId value to ensure it is unique for each method.
updateData: The data on columns and values to update.
where: A filter to select desired rows to update.
It is an SQL WHERE clause excluding the WHERE itself such as column1 = 'stringValue' AND column2 = numericValue.
successCallback [optional][nullable]: The method to invoke when the asynchronous call completes successfully.
errorCallback [optional][nullable]: The method to invoke when an error occurs.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the parameter type is not compatible with the expected type for that parameter.
with error type IOError, if a DB operation has failed.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
reqId: A unique identifier for the current operation.
So a developer should increase the reqId value to ensure it is unique for each method.
where: A filter to select desired rows to remove.
It is an SQL WHERE clause excluding the WHERE itself such as column1 = 'stringValue' AND column2 = numericValue.
successCallback [optional][nullable]: The method to invoke when the asynchronous call completes successfully.
errorCallback [optional][nullable]: The method to invoke when an error occurs.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the parameter type is not compatible with the expected type for that parameter.
with error type IOError, if a DB operation has failed.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
function successcb(id)
{
console.log("ok : reqid " + id);
}
function errorcb(id, error)
{
console.log("error id : " + id + ", error msg : " + error.message);
}
try {
// Defines globalReqId before
// Increases globalReqId for uniqueness
globalReqId++;
globalSQLConsumer.remove(globalReqId, "WORD='tizen1'", successcb, errorcb);
} catch (err) {
console.log (err.name +": " + err.message);
}
select
Selects the specified columns to be queried. The result set of the specified columns is retrieved from a table owned by an SQL-type data control provider.
reqId: A unique identifier for the current operation.
So a developer should increase the reqId value to ensure it is unique for each method.
columns: The columns to select.
where: A filter to select desired rows.
It is an SQL WHERE clause excluding the WHERE itself such as column1 = 'stringValue' AND column2 = numericValue.
successCallback: The method to invoke when the asynchronous call completes successfully.
errorCallback [optional][nullable]: The method to invoke when an error occurs.
page [optional][nullable]: The page number of the result set.
It starts from 1. If the number is out of page, DataControlSelectSuccessCallback is invoked with no result data.
maxNumberPerPage [optional][nullable]: The maximum number of rows on a page. The maximum allowed value is equal to 1024.
order [optional][nullable]: The sorting order of the selected rows.
It is an SQL ORDER BY clause excluding the ORDER BY itself such as column1, column2 ASC. If it is set to null, the order in which the rows are returned is undefined.
Exceptions:
WebAPIException
with error type TypeMismatchError, if the parameter type is not compatible with the expected type for that parameter.
with error type IOError, if a DB operation has failed.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if any other error occurs.
Code example:
function getValueSuccessCB(result, id)
{
console.log("getValueSuccessCB result.length: " + result.length);
var length = result.length;
for (var i = 0; i < length; i++)
{
var rowData = "| ";
var j = 0;
for (j = 0; j < result[i].columns.length; j++)
{
rowData += "column: " + result[i].columns[j] + ", value: " + result[i].values[j] + " | ";
}
console.log(rowData);
}
}
function errorcb(id, error)
{
console.log("error id : " + id + ", error msg : " + error.message);
}
try {
// globalSQLConsumer and globalReqId should be defined before.
// Increases globalReqId for uniqueness
globalReqId++;
var columns = ["WORD", "WORD_DESC" ];
var whereClause = "1";
console.log("----- Calling for ascending order -----");
globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb,
null, null, "WORD_DESC ASC");
setTimeout( function() {
console.log("----- Calling descending order -----");
globalSQLConsumer.select(globalReqId, columns, whereClause, getValueSuccessCB, errorcb,
null, null, "WORD_DESC DESC");
}, 1000);
}
catch (err) {
console.log (err.name +": " + err.message);
}
void onsuccess(RowData[] rows, unsigned long reqId);
Since 2.4
Parameters:
rows: Rows of SQL selection results from another application.
The array operation of rows would be different from general JavaScript array behavior depending on platform implementation. For example, Array.isArray(rows) returns false.
reqId: A unique identifier for the current operation.
So it is recommended to increase the reqId value every time to guarantee uniqueness.
2.10. DataControlGetValueSuccessCallback
This interface provides a SuccessCallback for MapDataControlConsumer.getValue().
data: Object with information of columns and values of changed data. Actual data to be returned depends on data returned by data control provider application. Please refer to native documentation.
2.11. RowData
The dictionary represents RowData holding 1 row of SQL selection results from another application.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.