Example usage for android.app DownloadManager ERROR_INSUFFICIENT_SPACE

List of usage examples for android.app DownloadManager ERROR_INSUFFICIENT_SPACE

Introduction

In this page you can find the example usage for android.app DownloadManager ERROR_INSUFFICIENT_SPACE.

Prototype

int ERROR_INSUFFICIENT_SPACE

To view the source code for android.app DownloadManager ERROR_INSUFFICIENT_SPACE.

Click Source Link

Document

Value of #COLUMN_REASON when there was insufficient storage space.

Usage

From source file:Main.java

public static void CheckDwnloadStatus(DownloadManager downloadManager, Activity activity, long id) {

    // TODO Auto-generated method stub
    DownloadManager.Query query = new DownloadManager.Query();
    query.setFilterById(id);//  w ww  .j a va2  s  .  co m
    Cursor cursor = downloadManager.query(query);
    if (cursor.moveToFirst()) {
        int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
        int status = cursor.getInt(columnIndex);
        int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
        int reason = cursor.getInt(columnReason);

        switch (status) {
        case DownloadManager.STATUS_FAILED:
            String failedReason = "";
            switch (reason) {
            case DownloadManager.ERROR_CANNOT_RESUME:
                failedReason = "ERROR_CANNOT_RESUME";
                break;
            case DownloadManager.ERROR_DEVICE_NOT_FOUND:
                failedReason = "ERROR_DEVICE_NOT_FOUND";
                break;
            case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
                failedReason = "ERROR_FILE_ALREADY_EXISTS";
                break;
            case DownloadManager.ERROR_FILE_ERROR:
                failedReason = "ERROR_FILE_ERROR";
                break;
            case DownloadManager.ERROR_HTTP_DATA_ERROR:
                failedReason = "ERROR_HTTP_DATA_ERROR";
                break;
            case DownloadManager.ERROR_INSUFFICIENT_SPACE:
                failedReason = "ERROR_INSUFFICIENT_SPACE";
                break;
            case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
                failedReason = "ERROR_TOO_MANY_REDIRECTS";
                break;
            case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
                failedReason = "ERROR_UNHANDLED_HTTP_CODE";
                break;
            case DownloadManager.ERROR_UNKNOWN:
                failedReason = "ERROR_UNKNOWN";
                break;
            default:
                failedReason = "unknown reason";
                break;
            }

            Toast.makeText(activity, "FAILED: " + failedReason, Toast.LENGTH_LONG).show();
            break;
        case DownloadManager.STATUS_PAUSED:
            String pausedReason = "";

            switch (reason) {
            case DownloadManager.PAUSED_QUEUED_FOR_WIFI:
                pausedReason = "PAUSED_QUEUED_FOR_WIFI";
                break;
            case DownloadManager.PAUSED_UNKNOWN:
                pausedReason = "PAUSED_UNKNOWN";
                break;
            case DownloadManager.PAUSED_WAITING_FOR_NETWORK:
                pausedReason = "PAUSED_WAITING_FOR_NETWORK";
                break;
            case DownloadManager.PAUSED_WAITING_TO_RETRY:
                pausedReason = "PAUSED_WAITING_TO_RETRY";
                break;
            }

            Toast.makeText(activity, "PAUSED: " + pausedReason, Toast.LENGTH_LONG).show();
            break;
        case DownloadManager.STATUS_PENDING:
            Toast.makeText(activity, "PENDING", Toast.LENGTH_LONG).show();
            break;
        case DownloadManager.STATUS_RUNNING:
            Toast.makeText(activity, "RUNNING", Toast.LENGTH_LONG).show();
            break;
        case DownloadManager.STATUS_SUCCESSFUL:

            Toast.makeText(activity, "SUCCESSFUL", Toast.LENGTH_LONG).show();
            break;
        }
    }
}

From source file:de.elanev.studip.android.app.frontend.courses.CourseDocumentsFragment.java

private static int getDownloadFailedReason(int queryReason) {
    switch (queryReason) {
    case DownloadManager.ERROR_CANNOT_RESUME:
        return R.string.error_cannot_resume;

    case DownloadManager.ERROR_DEVICE_NOT_FOUND:
        return R.string.error_device_not_found;

    case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
        return R.string.error_file_already_exists;

    case DownloadManager.ERROR_FILE_ERROR:
        return R.string.error_file_error;

    case DownloadManager.ERROR_HTTP_DATA_ERROR:
        return R.string.error_http_data_error;

    case DownloadManager.ERROR_INSUFFICIENT_SPACE:
        return R.string.error_insufficient_space;

    case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
        return R.string.error_to_many_redirects;

    case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
        return R.string.error_unhandled_error_code;

    default:// w  w  w. ja v  a2  s  .  co m
        return R.string.unknown_error;
    }

}

From source file:com.cypher.cota.helpers.DownloadHelper.java

private static int getDownloadError(Cursor cursor) {
    int columnReason = cursor.getColumnIndex(DownloadManager.COLUMN_REASON);
    int reasonText;
    try {/*www. ja va 2s . c  o  m*/
        int reason = cursor.getInt(columnReason);
        switch (reason) {
        case DownloadManager.ERROR_CANNOT_RESUME:
            reasonText = R.string.error_cannot_resume;
            break;
        case DownloadManager.ERROR_DEVICE_NOT_FOUND:
            reasonText = R.string.error_device_not_found;
            break;
        case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
            reasonText = R.string.error_file_already_exists;
            break;
        case DownloadManager.ERROR_FILE_ERROR:
            reasonText = R.string.error_file_error;
            break;
        case DownloadManager.ERROR_HTTP_DATA_ERROR:
            reasonText = R.string.error_http_data_error;
            break;
        case DownloadManager.ERROR_INSUFFICIENT_SPACE:
            reasonText = R.string.error_insufficient_space;
            break;
        case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
            reasonText = R.string.error_too_many_redirects;
            break;
        case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
            reasonText = R.string.error_unhandled_http_code;
            break;
        case DownloadManager.ERROR_UNKNOWN:
        default:
            reasonText = R.string.error_unknown;
            break;
        }
    } catch (CursorIndexOutOfBoundsException ex) {
        // don't crash, just report it
        reasonText = R.string.error_unknown;
    }
    return reasonText;
}

From source file:org.apache.cordova.backgroundDownload.BackgroundDownload.java

private String getUserFriendlyReason(int reason) {
    String failedReason = "";
    switch (reason) {
    case DownloadManager.ERROR_CANNOT_RESUME:
        failedReason = "ERROR_CANNOT_RESUME";
        break;/*w w  w.jav  a2 s . co  m*/
    case DownloadManager.ERROR_DEVICE_NOT_FOUND:
        failedReason = "ERROR_DEVICE_NOT_FOUND";
        break;
    case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
        failedReason = "ERROR_FILE_ALREADY_EXISTS";
        break;
    case DownloadManager.ERROR_FILE_ERROR:
        failedReason = "ERROR_FILE_ERROR";
        break;
    case DownloadManager.ERROR_HTTP_DATA_ERROR:
        failedReason = "ERROR_HTTP_DATA_ERROR";
        break;
    case DownloadManager.ERROR_INSUFFICIENT_SPACE:
        failedReason = "ERROR_INSUFFICIENT_SPACE";
        break;
    case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
        failedReason = "ERROR_TOO_MANY_REDIRECTS";
        break;
    case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
        failedReason = "ERROR_UNHANDLED_HTTP_CODE";
        break;
    case DownloadManager.ERROR_UNKNOWN:
        failedReason = "ERROR_UNKNOWN";
        break;
    }

    return failedReason;
}

From source file:org.chromium.chrome.browser.download.OMADownloadHandler.java

/**
 * Called when android DownloadManager fails to download the content.
 *
 * @param downloadInfo The information about the download.
 * @param reason The reason of failure.// ww  w  .  j a  va  2  s.c  om
 * @param notifyURI The previously saved installNotifyURI attribute.
 */
public void onDownloadFailed(DownloadInfo downloadInfo, int reason, String notifyURI) {
    String status = DOWNLOAD_STATUS_DEVICE_ABORTED;
    switch (reason) {
    case DownloadManager.ERROR_CANNOT_RESUME:
        status = DOWNLOAD_STATUS_LOSS_OF_SERVICE;
        break;
    case DownloadManager.ERROR_HTTP_DATA_ERROR:
    case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
    case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
        status = DOWNLOAD_STATUS_LOADER_ERROR;
        break;
    case DownloadManager.ERROR_INSUFFICIENT_SPACE:
        status = DOWNLOAD_STATUS_INSUFFICIENT_MEMORY;
        break;
    default:
        break;
    }
    long downloadId = (long) downloadInfo.getDownloadId();
    OMAInfo omaInfo = mPendingOMADownloads.get(downloadId);
    if (omaInfo == null) {
        // Just send the notification in this case.
        omaInfo = new OMAInfo();
        omaInfo.addAttributeValue(OMA_INSTALL_NOTIFY_URI, notifyURI);
        sendInstallNotificationAndNextStep(omaInfo, downloadInfo, status);
        return;
    }
    showDownloadWarningDialog(R.string.oma_download_failed, omaInfo, downloadInfo, status);
    mPendingOMADownloads.remove(downloadId);
}

From source file:se.bitcraze.crazyfliecontrol.bootloader.FirmwareDownloader.java

public String getReasonString(int reason) {
    String reasonText = "";
    switch (reason) {
    case DownloadManager.ERROR_CANNOT_RESUME:
        reasonText = "ERROR_CANNOT_RESUME";
        break;//from   w  w  w.ja va 2s  . c  o  m
    case DownloadManager.ERROR_DEVICE_NOT_FOUND:
        reasonText = "ERROR_DEVICE_NOT_FOUND";
        break;
    case DownloadManager.ERROR_FILE_ALREADY_EXISTS:
        reasonText = "ERROR_FILE_ALREADY_EXISTS";
        break;
    case DownloadManager.ERROR_FILE_ERROR:
        reasonText = "ERROR_FILE_ERROR";
        break;
    case DownloadManager.ERROR_HTTP_DATA_ERROR:
        reasonText = "ERROR_HTTP_DATA_ERROR";
        break;
    case DownloadManager.ERROR_INSUFFICIENT_SPACE:
        reasonText = "ERROR_INSUFFICIENT_SPACE";
        break;
    case DownloadManager.ERROR_TOO_MANY_REDIRECTS:
        reasonText = "ERROR_TOO_MANY_REDIRECTS";
        break;
    case DownloadManager.ERROR_UNHANDLED_HTTP_CODE:
        reasonText = "ERROR_UNHANDLED_HTTP_CODE";
        break;
    case DownloadManager.ERROR_UNKNOWN:
        reasonText = "ERROR_UNKNOWN";
        break;
    case DownloadManager.PAUSED_QUEUED_FOR_WIFI:
        reasonText = "PAUSED_QUEUED_FOR_WIFI";
        break;
    case DownloadManager.PAUSED_UNKNOWN:
        reasonText = "PAUSED_UNKNOWN";
        break;
    case DownloadManager.PAUSED_WAITING_FOR_NETWORK:
        reasonText = "PAUSED_WAITING_FOR_NETWORK";
        break;
    case DownloadManager.PAUSED_WAITING_TO_RETRY:
        reasonText = "PAUSED_WAITING_TO_RETRY";
        break;
    case 404:
        reasonText = "404 - NOT FOUND";
        break;
    case 403:
        reasonText = "403 - FORBIDDEN";
        break;
    case 401:
        reasonText = "401 - UNAUTHORIZED";
        break;
    case 500:
        reasonText = "500 - INTERNAL SERVER ERROR";
        break;
    case 503:
        reasonText = "503 - SERVICE UNAVAILABLE";
        break;
    default:
        reasonText = "" + reason;
        break;
    }
    return reasonText;
}