Tizen(Headless) Native API
6.0
|
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 |
---|---|
APP_RESOURCE_TYPE_IMAGE | Image resources. |
APP_RESOURCE_TYPE_LAYOUT | Application's layout to be displayed. |
APP_RESOURCE_TYPE_SOUND | Sound, audio resources. |
APP_RESOURCE_TYPE_BIN | All other resources to be needed, but not specified above. |
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
enum app_resource_e |
enum app_resource_error_e |
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. The path should be released using free().
- Parameters:
-
[in] type Resource type
- See also:
- app_resource_e
- Parameters:
-
[in] id Resource ID [out] path The name of requested resource on success, otherwise NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
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 Internal 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_NONE Successful APP_RESOURCE_ERROR_IO_ERROR IO Internal I/O Error APP_RESOURCE_ERROR_OUT_OF_MEMORY Out of memory
- See also:
- app_resource_manager_release()
int app_resource_manager_release | ( | void | ) |
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_NONE Successful
- See also:
- app_resource_manager_init()