Download .db file with Android DownloadManager
<p>I am attempting to download a .db file from my organization's website within an Android application and have encountered difficulties. It says the download is unsuccessful.</p>

<p>Here is the code that handles the download:</p>

<pre><code>package midamcorp.com.burgerkingapp;

import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.widget.Toast;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

public class downloadReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context c, Intent i) {
   File localDBFile = new File(c.getFilesDir(), "bk.db");

        try {

                    DownloadManager manager = (DownloadManager) c.getSystemService(Context.DOWNLOAD_SERVICE);


            Uri uriTest = Uri.parse("http://www.midamcorp.com/bk.db");

                    DownloadManager.Request request = new DownloadManager.Request(uriTest);


         if (localDBFile.exists()) {
                    localDBFile.delete();
                 }

                    manager.enqueue(request);

               //  }


  }
         catch(Exception ex) {
            Log.e("Error", ex.getMessage());
        }
}

        }
</code></pre>

<p>Furthermore, when I navigate to this file in my browser, I receive a 404 error; however, I know the path is correct. I have a feeling it has to do with the file extension (.db). How can I fix this?</p>

<p>Thanks!</p>