<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_user_application_data_directory(directory):
 """ Sets the user Application data directory. :param directory: Starting point for the directories tree creation. :type directory: unicode :return: Definition success. :rtype: bool """


    LOGGER.debug("> Current Application data directory '{0}'.".format(directory))
    if foundations.io.set_directory(directory):
        for sub_directory in Constants.preferences_directories:
            if not foundations.io.set_directory(os.path.join(directory, sub_directory)):
                raise OSError("{0} | '{1}' directory creation failed , '{2}' will now close!".format(
                    __name__, os.path.join(directory, sub_directory), Constants.application_name))
        return True
    else:
        raise OSError("{0} | '{1}' directory creation failed , '{2}' will now close!".format(__name__,
                                                                                             directory,
                                                                                             Constants.application_name))