logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Cache management


Function overview

With the ZIM SDK, you can query the local cache file size of the currently logged-in user and clear the local cache.

Query cache

After creating a ZIM object and logging in, you can invoke the queryLocalFileCache interface and pass ZIMFileCacheQueryConfig to query the size of the cache for the current user locally.

The query result will be returned through the callback interface ZIMFileCacheQueriedCallback.

Untitled
ZIMFileCacheQueryConfig config = new ZIMFileCacheQueryConfig ();
config.endTime = 0; // Query the cache size of the current user before this timestamp (UNIX).
                    // Fill in 0 or a value later than the current time to get the full cache size of the current user.
zim.queryLocalFileCache(config,  new ZIMFileCacheQueriedCallback() {
    @Override
    public void onFileCacheQueried(ZIMFileCacheInfo fileCacheInfo, ZIMError errorInfo) {
        if(errorInfo.code == ZIMErrorCode.SUCCESS) {
          // Query results
        } else {
          // ......
        }      
    }
});
1
Copied!

Clear cache

After creating a ZIM object and logging in, you can invoke the clearLocalFileCache interface and pass ZIMFileCacheClearConfig to clear the cache for the current user locally.

The clearing result will be returned through the callback interface ZIMFileCacheClearedCallback.

Untitled
ZIMFileCacheClearConfig config = new ZIMFileCacheClearConfig ();
config.endTime = 0; // Clear the cache of the current user before this timestamp (UNIX).
                    // Fill in 0 or a value later than the current time to clear the complete cache of the current user.
zim.clearLocalFileCache(config,  new ZIMFileCacheClearedCallback() {
    @Override
    public void onFileCacheCleared(ZIMError errorInfo) {
        if(errorInfo.code == ZIMErrorCode.SUCCESS) {
          // Get the result of clearing the cache.
        } else {
          // ......
        }      
    }
});
1
Copied!

Previous

Mark conversations

Next

Overview