Tizen D.I.T

Preference

D.I.T

#include "Device/Preference.h"
#include "Interface/Log.h"
#include "dit.h"

void Preference_use ()
{
    Preference p = NewPreference ();
    // Preference 모듈 생성
    p->setInt ("DIT", 123);
    LOGINFO("DIT", "%d", p->GetInt ("DIT", 0));
    // Preference Int
    p->setDouble ("DIT", 1.2);
    LOGINFO("DIT", "%lf", p->GetDouble ("DIT", 0.0));
    // Preference Double
    p->setBoolean ("DIT", true);
    LOGINFO("DIT", "%s", p->getBoolean ("DIT", false) ? "TRUE" : "FALSE");
    // Preference Boolean
    p->setString ("DIT", "TestMessage");
    String ret = NULL;
    ret = p->getString ("DIT", NULL);
    LOGINFO("DIT", "%s", ret);
    free (ret);
    // Preference String
    DestroyPreference (p);
    // Preference 모듈 삭제
}

Native

#include <stdlib.h>
#include <string.h>
#include <app_preference.h>
#include <dlog.h>

void Preference_use ()
{
    preference_error_e;

    preference_set_int ("DIT", 123);
    int ret_int;
    error = preference_get_int ("DIT", &ret_int);
    if ( error == PREFERENCE_ERROR_NONE )
    {
        dlog_print (DLOG_INFO, "DIT", "%d", ret);
    }
    else
    {
        dlog_print (DLOG_INFO, "DIT", "%d", 0);
    }
    // Preference Int

    preference_set_double ("DIT", 1.2);
    double ret_double;
    error = preference_get_double ("DIT", &ret_double);
    if ( error == PREFERENCE_ERROR_NONE )
    {
        dlog_print (DLOG_INFO, "DIT", "%lf", ret_double);
    }
    else
    {
        dlog_print (DLOG_INFO, "DIT", "%lf", 0.0);
    }
    // Preference Double

    preference_set_boolean ("DIT", true);
    bool ret_bool;
    error = preference_get_boolean ("DIT", &ret_bool);
    if ( error == PREFERENCE_ERROR_NONE )
    {
        dlog_print (DLOG_INFO, "DIT", "%s", ret_bool ? "TRUE" : "FALSE");
    }
    else
    {
        dlog_print (DLOG_INFO, "DIT", "%s", "FALSE");
    }
    // Preference Boolean

    setPreferenceString ("DIT", "TestMessage");
    char * ret_string = NULL;
    error = preference_get_string (key, &ret_string);
    if ( error == PREFERENCE_ERROR_NONE )
    {
        dlog_print (DLOG_INFO, "DIT", "%s", ret_string);
    }
    else
    {
        dlog_print (DLOG_INFO, "DIT", "%s", "");
    }
    free (ret_string);
    // Preference String
}