How do you remove .geodatabase file while App is running?

3017
2
11-22-2015 09:23 PM
TobiasFimpel1
Occasional Contributor III

I have an AppStudio app that generates+syncs a runtime geodatabase from a feature service and then displays some layers on a map. How can I give my users the ability to remove that .geodatabase file while the app is running?

In my app I have a button that when clicked:

1) removes all FeatureLayers from the map

2) changes all GeodatabaseFeatureTables to not point to my .geodatabase file anymore

Then it executes FileFolder.removeFile("gdb.geodatabase"), but it fails to delete the file!

In my code I do declare a QML Geodatabase component that uses the "gdb.geodatabase" file, and when I comment that section out the file does indeed get deleted successfully. Can I modify my Geodatabase component to not prevent the deletion of my .geodatabase file while the app is running? I tried changing the Geodatabase "path" property but that doesn't seem to release the lock.

Thanks for you advice.

Tags (1)
0 Kudos
2 Replies
PaulHaakma
Regular Contributor

Tobias

I've had similar experience here.

In theory, my assumption would be that when you have a map object open that has accessed a file then the file would be locked (this makes sense). If you're app was following a workflow where perhaps you used a stackview object to enter the app, then push a particular map to the front, then pop it off (destroy it) and return to some 'main menu', then I would expect it to release the file lock and allow you to delete the file. This is kind of the workflow that happens in Collector where you can remove maps from the main menu.

However, my experience has been that not only does this not release the file lock, but even exiting the app sometimes retains the file lock. On Windows, going into the Task Manager usually leads to discovering an active process still there even though the app has been closed. Killing this process usually releases the lock and allows to delete the file. This appears to be a bug of some sort - I had a brief discussion with someone at Esri at one point who was able to replicate it, but I'm not sure whether it's still logged as an active issue or not - perhaps some one from Esri could clarify?

My workaround at this point was to allow the user to set a variable to yes which on the next restart of the app deletes the file before it gets accessed. It's a bit crude and annoying but it works for now.

TobiasFimpel1
Occasional Contributor III

Thanks for your insight Paul, that makes sense.

0 Kudos