Languages

Menu
Sites
Language
Shared data storage for multiple tizen web apps
Is it possible to create a shared data storage for tizen web apps except the file api? I am planning to store key-value pairs. The HTML5 web storage is per application only.

Responses

11 Replies
Palitsyna

Hello,

May be you are looking for Data Control API. 

Data control allows you to read and modify data stored and provided by another application. The application storing and controlling the data is called a DataControl provider application. The application using the data is called a DataControl consumer application. A single DataControl provider can serve multiple DataControl consumers. The main data control features are: Data storage as key-value pairs and complex data storage using a SQL-type database and queries.

Here you'll find more information:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.tutorials/html/web/tizen/application/data_tutorial_w.htm#map

Nicole Provido

Thank you. I came across with this API but it seems like it requires a running native application which acts as the provider? Is it possible for a web app to be a provider? That is, can we use Data control API with just web apps?

Palitsyna

As far as I understood, this API requires native service app as data provider. Unfortunately, I think it's not possible to use it without native app.

Prajith Premanandan

Hi Nicole

U can use tizen metadata element " U can share information with other webapps The defined metadata can be accessed (read-only) through the Tizen Application API."

For more information

Please refer 

https://developer.tizen.org/documentation/development-tools/web-tools/configuration-editor

[Search for <TIZEN:METADATA />]

I hope this will be helpfull

 

Seoghyun Kang

Hello,


There are some ways to share the data with other web apps. It should be selected according to your situation.


If there is no need to modify the data, you can use the "METADATA" as Prajith Premanandan's comment.

But, If you use the METADATA, I remember that you can not change the value.


The usage of the "METADATA"  is very simple.


[Provider]  appID:k7GgAybiuE.A00

You need to add the following code to the config.xml.

<tizen:metadata key="version" value="1.0"/>

 


[Consumer]

- You should add the "<tizen:privilege name="http://tizen.org/privilege/application.info"/>" to config.xml.

//Initialize function
var init = function () {
    var metaDataArray = tizen.application.getAppMetaData("k7GgAybiuE.A00");
 
    console.log("size of metadata : " + metaDataArray.length);
    console.log(metaDataArray[0].value);
};

 


By the way, because Tizen mobile web platform does not support the app-serivce, I do not recommend the "Datacontrol".

But you can use it according to your situation.

 

As your comment, we can use the File API for the sharing the data.

I think it is also a good way to share the data now.

 

Please refer it.

Thanks

 

 

 


 

Gunwang Jeong

Hi,

The MessagePort API provides the functionality for communicating with other applications.
The message data type for the communication is map data, which consists of a string key and value pair.

Here you'll find more information:

https://developer.tizen.org/documentation/guides/web-application/tizen-features/inputoutput/message-port

Nicole Provido

Thanks. I am currently using this but it requires both apps to be running.

Marco Buettner

You can use FileSystem and store your data to phone/sdcard

var location = "documents";

// export data (export_data) to filesystem (export_data should be JSON)
function exportData(export_data) {
    function onerror(error) {
        console.error('error := '+error.message);
    }

    function writeToFile(stream) {
        stream.write(export_data);
        strea.close();
    }

    function onsuccess(dir) {
        var exportFile = null,
            mode = 'w';

        try // if file doesnt exist
        {
            exportFile = dir.createFile('export.txt');
        }
        catch (e) { // if file already exists
            exportFile = dir.resolve('export.txt');
            mode = 'a';
        }

        if(!exportFile)
        {
            exportFile.openStream(mode, writeToFile, onerror, 'UTF-8');
        }
    } 
    
    tizen.filesystem.resolve(location, onsuccess, onerror, 'rw');
}

// import data from filesystem
function importData(import_data) {
    function onerror(error) {
        console.error('error := '+error.message);
    }

    function readSuccess(content) {
        console.log("show me the content := "+content);
        localStorage.setItem('external_app_data', content);
        // DO SOMETHING WITH CONTENT
    }

    function onsuccess(dir) {
        var importFile = null;

        try { // if file exists
            importFile = dir.resolve('export.txt');

            importFile.readAsText(readSuccess, onerror, 'UTF-8');
        }
        catch (e) { // if file doesnt exist
            console.error("exception := "+e.message);
        }
    } 
    
    tizen.filesystem.resolve(location, onsuccess, onerror, 'rw');
}

 

Marco Buettner

small mistake in the code above

strea.close();

should be correct

stream.close();

 

Marco Buettner

All information about filesystem you can find on the documentation

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.web.apireference/html/device_api/mobile/tizen/filesystem.html

AVSukhov

Hello,

just fyi you can use shared/data directory of your app to share data by any ather apps using filesyatem api