Error 1014 SQLite cannot open

289
3
Jump to solution
02-06-2024 09:22 AM
DuanePfeiffer
New Contributor III

I am experiencing a strange error when opening a just-downloaded .mmpk.  It only happens on the first download of the day.  All subsequent downloads and opens of the same .mmpk work just fine.  Same thing when I use a different iPad to download to.  Here are some code snippets:

 

// destination
toURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)

// after download code
            // SUCCESS, SAVE FILE
            if FileManager.default.fileExists(atPath: toURL.path) {
                try FileManager.default.removeItem(atPath: toURL.path)
            }
            try data.write(to: toURL)

 

0 Kudos
1 Solution

Accepted Solutions
DuanePfeiffer
New Contributor III

Update:

This issue has been resolved by removing any references to the existing map before downloading and opening a new .mmpk

    public func DisposeMap()
    {
        mapLineTable = nil
        mapLineLayer = nil
        mapPointTable = nil
        mapPointLayer = nil
        geodatabase = nil
        map.removeAllOperationalLayers()
        map.removeAllTables()
        map = Map()
        if mobileMapPackage == nil { return }
        mobileMapPackage.close()
        mobileMapPackage = nil
}

View solution in original post

3 Replies
NimeshJarecha
Esri Regular Contributor

Hi @DuanePfeiffer ,

I'm not sure why you are getting SQLite 1014 error by just looking at the above code. However, there was another user who posted issue in the thread for the same error. Please check if same applied in your case. If not, I would appreciate if you can provide a reproducible Xcode project for us to debug. Please feel free to DM me.

Regards,

Nimesh

0 Kudos
DuanePfeiffer
New Contributor III

Thanks.  I saw that post but it doesn't apply to this issue.  I think I found the solution though.  I found some references to layers/tables in the currently loaded map that were not set to nil before loading the new map.  I'll have to check tomorrow's download to see if I fixed it.  I'll post back....

0 Kudos
DuanePfeiffer
New Contributor III

Update:

This issue has been resolved by removing any references to the existing map before downloading and opening a new .mmpk

    public func DisposeMap()
    {
        mapLineTable = nil
        mapLineLayer = nil
        mapPointTable = nil
        mapPointLayer = nil
        geodatabase = nil
        map.removeAllOperationalLayers()
        map.removeAllTables()
        map = Map()
        if mobileMapPackage == nil { return }
        mobileMapPackage.close()
        mobileMapPackage = nil
}