Search code examples
androidfiledownloadsizelimit

Android: what's Download manager File size Limitations


what's Downloadmanager downloadable File size Limitations in android, because I'm trying to download a file size (700MB) it's not downloaded but when i try same thing with 1MB or 2MB it's download perfect.

so, any help please


Solution

  • There is no documented limitation on file size, though available disk space would be one likely limit.

    For your failing downloads, use DownloadManager.Query to examine the COLUMN_STATUS and COLUMN_REASON values for your download, to try to determine what is going on.

    In this sample app, I download a file with DownloadManager, and a I have a button that allows you to view the status information.

    When you request a download, you get an int back that is a download request ID:

    lastDownload=mgr.enqueue(req);
    

    When the user clicks the appropriate button, I query for the download status, log some of that information to LogCat, and show a Toast:

      private void queryStatus(View v) {
        Cursor c=
            mgr.query(new DownloadManager.Query().setFilterById(lastDownload));
    
        if (c == null) {
          Toast.makeText(getActivity(), R.string.download_not_found,
                         Toast.LENGTH_LONG).show();
        }
        else {
          c.moveToFirst();
    
          Log.d(getClass().getName(),
                "COLUMN_ID: "
                    + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_ID)));
          Log.d(getClass().getName(),
                "COLUMN_BYTES_DOWNLOADED_SO_FAR: "
                    + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)));
          Log.d(getClass().getName(),
                "COLUMN_LAST_MODIFIED_TIMESTAMP: "
                    + c.getLong(c.getColumnIndex(DownloadManager.COLUMN_LAST_MODIFIED_TIMESTAMP)));
          Log.d(getClass().getName(),
                "COLUMN_LOCAL_URI: "
                    + c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)));
          Log.d(getClass().getName(),
                "COLUMN_STATUS: "
                    + c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)));
          Log.d(getClass().getName(),
                "COLUMN_REASON: "
                    + c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON)));
    
          Toast.makeText(getActivity(), statusMessage(c), Toast.LENGTH_LONG)
               .show();
    
          c.close();
        }
      }
    
      private String statusMessage(Cursor c) {
        String msg="???";
    
        switch (c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
          case DownloadManager.STATUS_FAILED:
            msg=getActivity().getString(R.string.download_failed);
            break;
    
          case DownloadManager.STATUS_PAUSED:
            msg=getActivity().getString(R.string.download_paused);
            break;
    
          case DownloadManager.STATUS_PENDING:
            msg=getActivity().getString(R.string.download_pending);
            break;
    
          case DownloadManager.STATUS_RUNNING:
            msg=getActivity().getString(R.string.download_in_progress);
            break;
    
          case DownloadManager.STATUS_SUCCESSFUL:
            msg=getActivity().getString(R.string.download_complete);
            break;
    
          default:
            msg=
                getActivity().getString(R.string.download_is_nowhere_in_sight);
            break;
        }
    
        return(msg);
      }