0

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

M.Honi
  • 123
  • 1
  • 1
  • 12

1 Answers1

1

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);
  }
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • so where i should put this 2 methods ?? – M.Honi May 07 '16 at 12:48
  • @M.Honi: You asked for an example. I gave you one. It is your job to learn from the example and apply it to your own situation. – CommonsWare May 07 '16 at 12:55
  • @M.Honi: Pending means that the Downloads app has not started the download yet, AFAIK. – CommonsWare May 07 '16 at 13:42
  • so what can i check ? – M.Honi May 07 '16 at 13:52
  • 1
    @M.Honi: There is nothing to "check". You are delegating the download work to an outside app. That app will do whatever it wants to do. For whatever reason, it is postponing downloading this file. If you want greater control over the download process, download the file yourself. – CommonsWare May 07 '16 at 13:55
  • 200mb https://android.googlesource.com/platform/packages/providers/DownloadProvider/+/fec5f50/src/com/android/providers/downloads/StorageManager.java#52 https://android.googlesource.com/device/moto/wingray/+/1560bdba946c7347fb55753605867f1565cee432%5E!/ – Thupten Jan 10 '17 at 22:01
  • @CommonsWare does the file size depend on memory size? how about if we are downloading using retrofit. The file will be consume into ResponseBody and depends on memory. Which is the best solution regarding file size limitation, using download manager or retrofit ? – Plugie Jan 31 '21 at 02:04
  • @Plugie: "does the file size depend on memory size?" -- that would surprise me. "how about if we are downloading using retrofit" -- I would use OkHttp directly, rather than the Retrofit wrapper around OkHttp. You can stream download content of arbitrary size using OkHttp. – CommonsWare Jan 31 '21 at 11:53