Select to view content in your preferred language

load tables and layers problem - SQLite cannot open. 1014

966
2
Jump to solution
11-11-2022 06:42 AM
MaksimsSenko
New Contributor

i get error on this line

code:

mapImageLayer.loadTablesAndLayers(completion: { [weak self] error in
self?.setupSublayers()
})

ArcGIS Runtime Error Occurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error: Error Domain=com.esri.arcgis.runtime.error Code=1014 "SQLite cannot open." UserInfo={NSLocalizedFailureReason=SQLite: 14
Unable to open the database file, NSLocalizedDescription=SQLite cannot open., Additional Message=SQLite: 14
Unable to open the database file}

 

after long research i found that it hapends after my app removes all data from temporary folder

func clearTmpDirectory() {
do {
let tmpDirURL = FileManager.default.temporaryDirectory
let tmpDirectory = try contentsOfDirectory(atPath: tmpDirURL.path)
try tmpDirectory.forEach { file in
let fileUrl = tmpDirURL.appendingPathComponent(file)
try removeItem(atPath: fileUrl.path)
}
} catch {
print("Failed to clear tmp folder")
}
}

i found that there is some folder that first creates when arcgis license is set

let result = try self.setLicenseKey("runtimelite,1000,**,none,***")

 

this folder dont recreates after second license set

it creates only when app is fully rebooted

 

before clearing temp directory layers and tables load works fine without problem

 

is this a bug or i do something incorrect?

 

in my business logic i need clear temp directory after user make logout, i cant skip this part.

0 Kudos
1 Solution

Accepted Solutions
MarkDostal
Esri Regular Contributor

Thank you for your question.  The arcgis subdirectory is for internal use only, and shouldn't be modified or, as you found out, things may not work correctly.  In general, it is not recommended to delete the temp folder contents of a running app as you may not know who/what has been storing files there.

I would recommend storing your temporary files that you may need to delete in a dedicated folder inside the temp directory and then just delete the files in that folder when necessary.  This will separate out your files from those that the ArcGIS SDK need (and other temporary files).

Let us know if you have any further questions.

Mark

View solution in original post

2 Replies
MaksimsSenko
New Contributor

I found property in UserDefaults.standard with key = "com.esri.arcgis.runtime.tempSubdirectory"

where is kept the name of this mystery subdirectory which is created by arcgis runtime

I will use this name to exclude it from deleting from temp directory

 

But I cant find information about this property in ArcGis Runtime iOS documentation, maybe somebody knows something about it?

I  also tried to set this property to my subdirectory, but it is impossible, in these case arcgis runtime works incorrectly too.

0 Kudos
MarkDostal
Esri Regular Contributor

Thank you for your question.  The arcgis subdirectory is for internal use only, and shouldn't be modified or, as you found out, things may not work correctly.  In general, it is not recommended to delete the temp folder contents of a running app as you may not know who/what has been storing files there.

I would recommend storing your temporary files that you may need to delete in a dedicated folder inside the temp directory and then just delete the files in that folder when necessary.  This will separate out your files from those that the ArcGIS SDK need (and other temporary files).

Let us know if you have any further questions.

Mark