语言

Menu
Sites
Language
how can I store datas ?

Hello, all.

I'm a beginner about native application development of Tizen .

During development, I have a question.

If I want to store datas such as settings value, how can I store them except for SQL ?

The datas I want to store are very simple.

(for example : name, gender, age, etc... for one person)

Among sample projects, can I refer any one  ?

If you know it, please let me know .

Thank you for your advice.

 

 

 

响应

2 回复
colin Rao

You can use the preference api to store simple key=value data for persistence. You can search "preference" on IDE help doc for dev guide.

Sample code:

const char *string_key = "string_key";
const char *string_value = "Sample content";
char *string_output;
const char *integer_key = "integer_key";
int integer_value = 1;
int integer_output;
bool existing;

existing = false;
if(preference_is_existing(string_key, &existing) == 0 && existing){
	preference_get_string(string_key, &string_output);
	dlog_print(DLOG_INFO, LOG_TAG, "[test_preference]string: %s.\n", string_output);
	free(string_output);
} else {
	preference_set_string(string_key, string_value);
}

existing = false;
if(preference_is_existing(integer_key, &existing) == 0 && existing){
        preference_get_int(integer_key, &integer_output);
	dlog_print(DLOG_INFO, LOG_TAG, "[test_preference]integer: %d.\n", integer_output);
} else {
	preference_set_int(integer_key, integer_value);
}

 

Jean Yang

Hello, 

 

You can you the bundle, also, you can check the data type which you prefer: please check below in IDE help.

Tizen Mobile Native App Programming > Tutorials > Application Framework Tutorials  
Bundle tutorial
Tizen Mobile Native App Programming > Programming Guide > UI: Creating the Application UI > Eina Data Types
using data types