Error: reading a geodatabase on a device

4168
10
Jump to solution
03-25-2014 02:30 AM
TorstenStruck
New Contributor
Hi,

I'm coding a small application (with SDK for iOS 10.2.2) for displaying an offline geodatabase that I have created with ArcGIS for Desktop 10.2.1. I have put the geodatabase into my application bundle and everything looks good on the xcode ipad simulator.
But on my "real" ipad I'm getting the following error message when creating the AGSGDBGeodatabase object:

Error Domain=com.esri.arcgis.runtime.error Code=6 "PRAGMA journal_mode = WAL;" UserInfo=0x170264bc0 {NSLocalizedDescription=PRAGMA journal_mode = WAL;}

Here's the code snippet for loading the geodatabase file (ltg.geodatabase):

   NSString *gdbPath = [[NSBundle mainBundle] pathForResource:@"ltg" ofType:@"geodatabase"];
   NSError* myerror;
   AGSGDBGeodatabase *gdb = [[AGSGDBGeodatabase alloc] initWithPath:gdbPath  error:&myerror];

Any ideas or solutions?

Thank you!
0 Kudos
1 Solution

Accepted Solutions
SuganyaBaskaran1
Esri Contributor
Thanks for reporting. This seems to be an issue in the SDK. We'll work on fixing it.

A work around for it is to use iTunes File Sharing and share the geodatabase through it.
To enable file sharing in your app, set the property "Application supports iTunes file sharing" to YES in Info.plist file. Then you should be able to add the geodatabase as described here

You can then create the geodatabase as follows:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *gdbPath = [paths objectAtIndex:0]; gdbPath = [gdbPath stringByAppendingPathComponent:@"ltg.geodatabase"]; if ([[NSFileManager defaultManager] fileExistsAtPath:gdbPath]) {    //create GDB here }


Hope this helps, please let us know if you have more questions.

View solution in original post

0 Kudos
10 Replies
SuganyaBaskaran1
Esri Contributor
Thanks for reporting. This seems to be an issue in the SDK. We'll work on fixing it.

A work around for it is to use iTunes File Sharing and share the geodatabase through it.
To enable file sharing in your app, set the property "Application supports iTunes file sharing" to YES in Info.plist file. Then you should be able to add the geodatabase as described here

You can then create the geodatabase as follows:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *gdbPath = [paths objectAtIndex:0]; gdbPath = [gdbPath stringByAppendingPathComponent:@"ltg.geodatabase"]; if ([[NSFileManager defaultManager] fileExistsAtPath:gdbPath]) {    //create GDB here }


Hope this helps, please let us know if you have more questions.
0 Kudos
ShiminCai
Occasional Contributor III
I bundled my geodatabase with my app. When my app started I copied the geodatabase from the app bundle to the app's Documents folder and then created the gdb from the copy in the Documents.
0 Kudos
TorstenStruck
New Contributor
Thank you! That worked fine!


Thanks for reporting. This seems to be an issue in the SDK. We'll work on fixing it.

A work around for it is to use iTunes File Sharing and share the geodatabase through it.
To enable file sharing in your app, set the property "Application supports iTunes file sharing" to YES in Info.plist file. Then you should be able to add the geodatabase as described here

You can then create the geodatabase as follows:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *gdbPath = [paths objectAtIndex:0];
gdbPath = [gdbPath stringByAppendingPathComponent:@"ltg.geodatabase"];
if ([[NSFileManager defaultManager] fileExistsAtPath:gdbPath]) {

  //create GDB here
}


Hope this helps, please let us know if you have more questions.
0 Kudos
SweetySingh
New Contributor
Which file type got worked .gdb or .geodatabase?
We are also facing same problem i.e unable to read data from .gdb file.

How we have to add it : locally in app or in documents directory?

Can you help with the steps how it got worked for you?


Thanks,
Sweety
0 Kudos
SivaVysyaraju
New Contributor II
I think it is .geodatabase file.
0 Kudos
SuganyaBaskaran1
Esri Contributor
Which file type got worked .gdb or .geodatabase?
We are also facing same problem i.e unable to read data from .gdb file.

How we have to add it : locally in app or in documents directory?



It's the .geodatabase file. Are you creating the file as outlined here ? This gives a .geodatabase file which you can add to the app through file sharing
0 Kudos
VIKRANTKRISHNA
New Contributor III
I need to package a demo geodataset along with app. How can I make this work, having geodatabase as part of project doesn't seems to work.
0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor
Hello Vikrant,

Use this line to load the local geodatabase:
[PHP]NSString *gdbPath = [[NSBundle mainBundle]pathForResource:@"gdb_file_name" ofType:@"geodatabase"];[/PHP]

This is a generic way about how to load a file from Resources folder in iOS:

http://www.android-ios-tutorials.com/257/read-files-in-resources-folder-ios/

Hope this can help.
0 Kudos
VIKRANTKRISHNA
New Contributor III
Nathan,
           This seems to be work for simulator, for iPad its giving error Domain=com.esri.arcgis.runtime.error code=12 "automatic extension loading failed:"
0 Kudos