Geodatabase geodatabase = null; File file = new File("/sdcard/geodatabase/GDB_Test.gdb"); try { geodatabase = new Geodatabase("/sdcard/geodatabase/GDB_Test.gdb"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); if (geodatabase != null) this.addressText.setText("ok"); else if (file.exists()) this.addressText.setText("can not read"); else this.addressText.setText("nothing"); } if (geodatabase != null) { for (GeodatabaseFeatureTable gdbFeatureTable : geodatabase .getGeodatabaseTables()) { if (gdbFeatureTable.hasGeometry()) mMapView.addLayer(new FeatureLayer(gdbFeatureTable)); } }
I tried to download the code from official tutorial website, the sample of code is "Offline routing". But it tells there are fatal error when I execute, I have already put the external files to the right path.
04-01 10:16:15.957: E/AndroidRuntime(30844): java.lang.UnsatisfiedLinkError: Couldn't load runtimecore_java from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.esri.arcgis.android.samples.offlineroutingandgeocoding-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.esri.arcgis.android.samples.offlineroutingandgeocoding-1, /vendor/lib, /system/lib]]]: findLibrary returned null
04-01 10:16:15.957: E/AndroidRuntime(30844): at java.lang.Runtime.loadLibrary(Runtime.java:358)
Thank you for help
Hi Zijian and Lisandro,
In your examples, are you using file geodatabases?
GDB_Test.gdb (Zijian)
RH_SampleData.gdb (Lisandro).
When using a geodatabase locally on an Android device you need to use a runtime geodatabase.
For a quick test or example, You could create runtime content using ArcMap. On ArcMap's File menu, point to Share as, and click Runtime content. There is a bit more to it than just clicking a menu choice. You can read more about the workflows here:
http://resources.arcgis.com/en/help/main/10.2/index.html#//00660000045q000000
ArcMap creates a .geodatabase file, that you can place on the Android device.
For example, using a file browser I copied the output city.geodatabase onto my phone's sd card. Then in Eclipse using the DDMS perspective you can see the file on the device and learn the folder names for the sd card. In code I make a variable to reference that location:
String gdbPath = "/storage/extSdCard/ArcGISApp/city.geodatabase";
//In a try...catch I create a Geodatabase object and use the path.
Geodatabase geodatabase = new Geodatabase(gdbPath);
//From there you can get FeatureTables by their index position. This line gets the first table using 0 as the index.
GeodatabaseFeatureTable geodatabaseFeatureTable = geodatabase.getGeodatabaseFeatureTableByLayerId(0);
//You can then use the table to create a feature layer and add the layer to the map.
FeatureLayer featureLayer = new FeatureLayer(geodatabaseFeatureTable);
mMapView.addLayer(featureLayer);
Please check out this page for more details on the patterns of working with offline data:
https://developers.arcgis.com/android/guide/create-an-offline-map.htm
Please let me know if this helps.