Tizen Native API  5.0
Resource Manager

The Resource Manager API provides functions to get/set the common resource for multiple devices.

Required Header

#include <app_resource_manager.h>

Overview

The Resource Manager API provides functions to use different resources(images, layout, sounds) between each device having different device specifications. For example, if you want to change button image of the application depending on the device's current language setting, put resource files into different folders which are managed by SDK as the same filename. Then call app_resource_manager_get() with resource ID described below to get the appropriate resource filepath, then OS will choose resources for specific devices. You should get the path of the resource file that is managed by the resource manager with app_resource_manager_get() API. Tizen may remove unnecessary resource files for a certain device, so you may fail to access if you access the resource file with the path that is not received with app_resource_manager_get() API. Make sure app_resource_manager_init() should be called first and app_resource_manager_release should be called after using resource manager.

Resource ID

Resource ID is an identifier for specific resource. It consists of sub directories and filename including its extension. Same resources are located at different locations with same filename for supporting multiple devices. If you want to get actual filename with given resourceID, refer app_resource_manager_get().

Resource Type

For now, 4 resource types are supported. Resource which has same resource type are grouped as folder. Folder name is irrelevant with its actual resource type. The managed folders for each type will be generated by SDK tools. In source codes, you can use resource types listed below. (Types will be added for further needs)

TYPE Description
RSC_TYPE_IMAGE Image resources.
RSC_TYPE_LAYOUT Application's layout to be displayed.
RSC_TYPE_SOUND Sound, audio resources.
RSC_TYPE_BIN All other resources to be needed, but not specified above.

Matching Algorithm

capi_appfw_application_resource.png
Matching Algorithm

Functions

int app_resource_manager_init (void)
 Creates resource manager and get from db.
int app_resource_manager_get (app_resource_e type, const char *id, char **path)
 Converts resource ID to path name.
int app_resource_manager_release (void)
 Destroys resource manager.

Enumeration Type Documentation

Enumeration for Resource Types.

Since :
2.4
Enumerator:
APP_RESOURCE_TYPE_IMAGE 

Image

APP_RESOURCE_TYPE_LAYOUT 

Edje

APP_RESOURCE_TYPE_SOUND 

Sound

APP_RESOURCE_TYPE_BIN 

Bin

Enumeration for App Resource Manager Error.

Since :
2.4
Enumerator:
APP_RESOURCE_ERROR_NONE 

Successful

APP_RESOURCE_ERROR_INVALID_PARAMETER 

Invalid parameter

APP_RESOURCE_ERROR_OUT_OF_MEMORY 

Out of memory

APP_RESOURCE_ERROR_IO_ERROR 

I/O error


Function Documentation

int app_resource_manager_get ( app_resource_e  type,
const char *  id,
char **  path 
)

Converts resource ID to path name.

Since :
2.4
Remarks:
If resource manager is not created yet, app_resource_manager_init() will be invoked automatically. Caller should free the returned pointer.
Parameters:
[in]typeResource type
See also:
app_resource_e
Parameters:
[in]idResource ID
[out]pathThe name of requested resource on success, otherwise NULL
Returns:
0 on success, otherwise a negative error value
Return values:
APP_RESOURCE_ERROR_NONESuccessful
APP_RESOURCE_ERROR_INVALID_PARAMETERInvalid Parameter
APP_RESOURCE_ERROR_OUT_OF_MEMORYOut of memory
APP_RESOURCE_ERROR_IO_ERRORInternal I/O Error or failed to find valid resource
See also:
app_resource_manager_init()
int app_resource_manager_init ( void  )

Creates resource manager and get from db.

Since :
2.4
Remarks:
If resource manager already exists, It will just return APP_RESOURCE_ERROR_NONE
Returns:
0 on success, otherwise a negative error value
Return values:
APP_RESOURCE_ERROR_NONESuccessful
APP_RESOURCE_ERROR_IO_ERRORIO Internal I/O Error
APP_RESOURCE_ERROR_OUT_OF_MEMORYOut of memory
See also:
app_resource_manager_release()

Destroys resource manager.

Since :
2.4
Remarks:
Please note that the instance of resource manager should only be released when the application is closing. It is a highly recommended way to improve run-time performance.
Returns:
0 on success, otherwise a negative error value
Return values:
APP_RESOURCE_ERROR_NONESuccessful
See also:
app_resource_manager_init()