Code example for NetworkErrorException

0
 
        /* 
         * check net work 
         */ 
        if (!NetworkUtils.isNetworkAvailable(context)) {
            throw new NetworkErrorException("Network blocked.");
        } 
 
        /* 
         * check file length 
         */ 
        client = AndroidHttpClient.newInstance("DownloadTask");
        httpGet = new HttpGet(url);
        response = client.execute(httpGet);
        totalSize = response.getEntity().getContentLength();
 
        if (file.exists() && totalSize == file.length()) {
            if (DEBUG) {
                Log.v(null, "Output file already exists. Skipping download.");
            }