Delete an OfflineMap MobileMapPackage and unregister replicas.

1260
6
09-05-2017 12:04 AM
marceloctorres
Esri Contributor

In a Xamarin.Forms app, when you create a MobileMapPackage using OfflineMapTask, how you delete or destroy that MobileMapPackage. If only delete file or directory that containing the MobileMapPackage, the replica created at the remote FeatureService is not unregistered and sometimes the file and directory containing it are blocked and can not be deleted unless the app is terminated and re-launched .

Marcelo César Torres
0 Kudos
6 Replies
AnttiKajanus1
Occasional Contributor III

Hi,

At the moment you have to use GeodatabaseSyncTask.UnregisterGeodatabaseAsync Method to manually unregister the geodatabases and make sure that you call Geodatabase.Close Method to release geodatabases so they can be deleted without any issues. Make also sure that you don't actually use offline mobile map / map package before you try to delete it. 

We are investigating ways to make this workflow a bit easier for the users so I'm happy to hear your experiences / thoughts related to the workflow and how hard it is to do.

by Anonymous User
Not applicable

I would second this - please do create an 'un-register' method on the OfflineMapSyncTask object (or where-ever it would need to sit) that cycles through and unregisters all geodatabases contained within.

Thanks for your notes below that outline how we can manually do this in the interim.

0 Kudos
marceloctorres
Esri Contributor

ok the point is that on the one hand it is easier to download the map with all the settings that it has (layers, visibility ranges, symbology, labeling, popups setting) with OfflineMapTask versus download the geodatabase and then by code redefine all configurations , but in the other hand it is a requirement of my app that these settings could be changed in the webmap and these changes must be reflected in the device.

Is there a way to extract or generate the geodatabase from MobileMapPackage?

Marcelo César Torres
0 Kudos
AnttiKajanus1
Occasional Contributor III

Yep, OfflineMapTask is mainly used to take the stuff offline, then it's up to the developer to add rest of the functionality. Note that there is also OfflineMapSyncTask that could help to do the synchronization related functionality. We are having a look if we can add functionality there to handle the unregister case as well. 

 
OfflineMapTask basically creates an exploded mobile map package to the target folder which contains all the geodatabases as well. Technically these are just normal files in the device so you can choose to work with them directly if you like. There are 2 relatively easy ways to get them 

1) Loop through your FeatureLayers and their GeodatabaseFeatureTables which contains reference to the Geodatabase  which has path to the file
2) find all .geodatabase files from the p13 folder (it contains all the packages that we export from the services) that is located in the offline map folder

marceloctorres
Esri Contributor

Thanks.... I solve my question.

Marcelo César Torres
0 Kudos
marceloctorres
Esri Contributor

Now I have another problem: How can I close the .tpk and .mmpk files before deleting them?

Marcelo César Torres
0 Kudos