Get all packages installed on the device

This snippet will let you get the information about all installed packages on the device. PRIVILEGES NEEDED: http://tizen.org/privilege/packagemanager.info
#include <stdlib.h>
#include <package_manager.h>
#include <dlog.h> //for logging purposes

//callback executed for each package found
bool package_info_cb(package_info_h package_info, void *user_data)
{
    char *pkg = NULL;
    if (package_info_get_package(package_info, &pkg) == PACKAGE_MANAGER_ERROR_NONE)
    {
        LOGI("Package found! package id: %s", pkg);
    }
    free(pkg);
    return true;
}

//for each installed package we execute a callback
int ret = PACKAGE_MANAGER_ERROR_NONE;
ret = package_manager_foreach_package_info(package_info_cb, NULL);
//do some error handling at your discretion...

Responses

0 Replies