Can I install the app on my phone but store the .mmpk files on the external storage card? If so how do I point to this new location?
I am using the Quick Report template....maybe there is a setting in the QuickReportApp.qml file?
There is no setting the in the Quick Report template to change the default storage location of the mmpk file, but this can be change in the code in QuickReport/controls/MmpkManager.qml ~80
Thank you,
Erwin
Perfect thanks....will give that a whirl....appreciated.
So if I am correct I think this is the line that I need to modify
var path = [fileFolder.path, "~"+itemName].join("/");
In the MmpkManager.qml file
I added line 13
commented line 15
added/modified line 16
I uploaded and did a make on the project....I downloaded and installed from AGOL and when I went offline it still saved the download to the Phone itself and not the SD Card:
SAMSUNG-SM-J727V\Phone\ArcGIS\AppStudio\Data\QuickReport
Am I missing something?
onReadyStateChanged: {
if (readyState === NetworkRequest.DONE ){
if(errorCode != 0){
loadStatus = 2;
} else {
var root = JSON.parse(responseText);
if(root.type == "Mobile Map Package"){
loadStatus = 1;
var component = networkRequestComponent;
var networkRequest = component.createObject(parent);
var url = rootUrl+itemId+"/data";
var fileslocation = "/mnt/sdcard/ArcGIS/AppStudio/Data/QuickReport/"
//var path = [fileFolder.path, "~"+itemName].join("/");
var path = [fileslocation, "~"+itemName].join("/");
networkRequest.downloadFile("~"+itemName, url, path, typeNetworkRequest.callback);
} else {
loadStatus = 2;
}
}
}
}
Can I change the code in this location at the top of the MmpkManager.qml ????
FileFolder{
id: fileFolder
//readonly property url storageBasePath: AppFramework.userHomeFolder.fileUrl("ArcGIS/AppStudio/Data")
readonly property url storageBasePath: "/mnt/sdcard/ext_sd/ArcGIS/AppStudio/Data"
property url storagePath: subFolder && subFolder>"" ? storageBasePath + "/" + subFolder : storageBasePath
url: storagePath
Component.onCompleted: {
if(!fileFolder.exists){
fileFolder.makeFolder(storagePath);
}
if(!fileFolder.fileExists(".nomedia") && Qt.platform.os === "android"){
fileFolder.writeFile(".nomedia", "");
}
}
}
Has anyone done this before.....I got this to work when I changed it to the C:/Temp/Test on my PC....but still cant get it to my phone storage card. The below first two examples show how I did this to my C Drive.
In the MmpkManager.qml file at the bottom if I change the readonly property url to the below nothing happens...
onReadyStateChanged: {
if (readyState === NetworkRequest.DONE ){
if(errorCode != 0){
loadStatus = 2;
} else {
var root = JSON.parse(responseText);
if(root.type == "Mobile Map Package"){
loadStatus = 1;
var component = networkRequestComponent;
var networkRequest = component.createObject(parent);
var url = rootUrl+itemId+"/data";
// ADDED
var fileslocation = "C:/Temp/tEST/QuickReport"
// COMMENTED OUT
//var path = [fileFolder.path, "~"+itemName].join("/");
// MODIFIED THE ABOVE TO THIS
var path = [fileslocation, "~"+itemName].join("/");
networkRequest.downloadFile("~"+itemName, url, path, typeNetworkRequest.callback);
} else {
loadStatus = 2;
}
}
}
}
If I then go to the top of the MmpkManager.qml file and change the below it no uses the C drive and shows the mmpk file through AppStudio when I run the project.
I have to make both changes to get it to work
FileFolder{
id: fileFolder
// COMMENTED OUT
//readonly property url storageBasePath: AppFramework.userHomeFolder.fileUrl("ArcGIS/AppStudio/Data")
// MODIFIED TO THIS
// THIS WORKS ON THE DESKTOP
readonly property url storageBasePath: "C:/Temp/tEST"
property url storagePath: subFolder && subFolder>"" ? storageBasePath + "/" + subFolder : storageBasePath
url: storagePath
Component.onCompleted: {
if(!fileFolder.exists){
fileFolder.makeFolder(storagePath);
}
if(!fileFolder.fileExists(".nomedia") && Qt.platform.os === "android"){
fileFolder.writeFile(".nomedia", "");
}
}
}
If I make the two above changes it works....I am then trying to modify that so I can use on my Phones SD Card and nothing works....
My question is am on on the right path? Are there any other modifications that I need to make to the code to get this to work?
I then try this...to get to the storage card
At the top of the MmpkManager.qml
readonly property url storageBasePath: "/storage/Test"
At the bottom of the MmpkManager.qml
var fileslocation = "/storage/Test/QuickReport"
var path = [fileslocation, "~"+itemName].join("/");
networkRequest.downloadFile("~"+itemName, url, path, typeNetworkRequest.callback);
Any one have any thoughts?
Jay,
The path to external storage card on every device and platform can be varied.
The best way to get the path to the external storage card (if present, I am assuming Android?) is by using the StorageInfo plugin from AppStudio AppFramework.
For example like this,
StorageInfo {
id: storageInfo
}
Component.onCompleted: {
var path, fs, dev;
var mountedVols = storageInfo.mountedVolumes;
for (var i = 0; i < mountedVols.length; i++) {
fs = mountedVols[i].fileSystemType;
console.log("file system type: ", fs);
dev = mountedVols[i].device
console.log("device: ", dev);
path = mountedVols[i].path;
console.log("path: ", path);
}
}
The path to the storage card normally starts with "/storage/..." or "/mnt/...
Thank you,
Erwin
Fantastic...this uncovered I had the path incorrect the whole time....going to give this a shot....
THANKS