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 null04-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#//00660000045q000000ArcMap 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.htmPlease let me know if this helps.
Is there any solution to use these functions without update the ArcGIS server?
This sample demonstrates the services pattern for generating a runtime geodatabase from a feature service.
The *.gdb file is for ArcGIS desktop, not for android. If you want to use vector data in android, you have to convert it to *.geodatabase.(1)In ArcGIS Desktop 10.2.2, open *.gdb file, use runtime content to convert to *.geodatbase.(2)Put the *.geodatbase in the android card. Geodatabase localGdb = new Geodatabase( geodatabasePath); for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseTables()) { if (gdbFeatureTable.hasGeometry()) map.addLayer(new FeatureLayer(gdbFeatureTable));
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.