APICloud gets the cache and clears the cache (commonly used third-party methods)

1. There is often a cache clearing operation in the app, as follows

1. Get the cache size

apiready = function() {
        api.getCacheSize(function(ret, err) {
            // size:         // The size of the cache, the unit is Byte, the number type. (-1: no storage device, -2: preparing USB storage device, -3: storage device cannot be accessed) 
            var size = parseInt(ret.size/ 1024 ) + ' KB ' ;
             var cacheSize = $api.byId( ' cacheSize ' );
            cacheSize.innerHTML = size;

        });
    };

2. Clear the cache method

function clearnCach(){
        api.clearCache(function() {
            api.toast({
                msg: ' Clear complete '
            });
        });
        api.getCacheSize(function(ret, err) {
            var size = parseInt(ret.size/1024) + 'KB';
            var cacheSize = $api.byId('cacheSize');
            cacheSize.innerHTML = size;
        });
    };

 2. Make a phone call

// make a call 
    function takePhone() {
        api.call({
            number:'029-83670111'
        });
    };

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325160680&siteId=291194637