# UtilCode **Repository Path**: openharmony-tpc/UtilCode ## Basic Information - **Project Name**: UtilCode - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2022-06-24 - **Last Updated**: 2025-04-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 🚨 **重要提示 | IMPORTANT** > > **⚠️ 此代码仓已归档。新地址请访问 [UtilCode](https://gitcode.com/openharmony-tpc/UtilCode)。| ⚠️ This repository has been archived. For the new address, please visit [UtilCode](https://gitcode.com/openharmony-tpc/UtilCode).** > --- > # OpenHarmonyUtilCode OpenHarmonyUtilCode library is a ETS Library that supports common utility functions like Clean Utility(Cleaning the Cache, files and application data), Location utility services (Commonly used location based services), Etc. ## Installation Instructions ```js npm i '@ohos/utilcode' ``` Details about OpenHarmony NPM environment configuration, see [here](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_npm_usage.md) ## Clean Utils Clean Utils is Open Harmony ETS Library that performs cleaning operations of an application and its data. Clean Utils can perform the following: * Cleaning the Internal Cache * Cleaning all the files of the application * Cleaning the custom directory of an application * Cleaning all databases of an application * Cleaning a custom database * Cleaning the Shared Preferences ### Importing Clean Utils ```js import { CleanUtils } from '@ohos/utilcode'; ``` ### CleanUtils Usage ```js //Creating Object private cleanutils: CleanUtils = new CleanUtils(); //function usage this.cleanutils.cleanInternalCache().then((path) => { .. }) this.cleanutils.cleanInternalFiles().then((path) => { .. }) this.cleanutils.cleanInternalSp().then((path) => { .. }) this.cleanutils.cleanInternalDbByName(dbName).then((name) => { .. }) this.cleanutils.cleanInternalDbs().then((path) => { .. }) this.cleanutils.cleanCustomDir(dirName).then((name) => { .. }) ``` ## Directory Structure ```` |---- UtilCode | |---- entry #Sample Code Folder | |---- src | |---- main | |---- ets | |---- MainAbility | |---- pages | |---- CleanUtilsSample.ets | |---- index.ets | |---- LocationUtilsSample.ets | |---- utilcode #utility library | |---- src | |---- main | |---- ets | |---- utils | |---- CleanUtils.ets | |---- LocationUtils.ets | |---- index.ets ```` ## Compatibility Supports OpenHarmony API Version 8 ## Code Contribution If you find any problems during usage, you can submit an [Issue](https://gitee.com/openharmony-tpc/UtilCode/issues) to us. Of course, we also welcome you to send us [PR](https://gitee.com/openharmony-tpc/UtilCode/pulls). ## Open source License This project is based on [Apache License 2.0](https://gitee.com/openharmony-tpc/UtilCode/blob/master/LICENSE) ,please enjoy and participate in open source freely.