mardi 6 janvier 2015

Download Sqlite database into app internal storage

I want to download a cell phone operator specific sqlite db on the app's installation. I have the following code to download the new_db using DownloadManager. But I get the following exception.



java.lang.RuntimeException: Unable to start activity
ComponentInfo{http://ift.tt/1fTwGXm}:
java.lang.SecurityException: Destination must be on external storage:
file:///data/data/com.xyz.abc/databases/new_db.gz


Code:



Uri uri=Uri.parse("http://download_url_of_mine?cellinfo=404_45_1_2");
String databasePath = context.getDatabasePath("existing_db.db").getParent();

lastDownload=
mgr.enqueue(new DownloadManager.Request(uri)
.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI |
DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle("Title")
.setDescription("Downloading Data Once for all.")
.setDestinationUri(Uri.fromFile(new File(databasePath+"/new_db.gz"))));


Any Help is much appreciated! Is it that DownloadManager should be used only for external data not for the data that I need to be inside the private access of app?


Aucun commentaire:

Enregistrer un commentaire