0

Im quite new in arcmap map and i have been spending more than 2 week stuck in how to show map offline. I have tried the code is attached but when i run the application.It crashes nothing to show. You can see my code and i also attached geodatabase file.

i follow this tutorial: http://www.activeg.com/agBlog/android-running-an-arcgis-map-offline

And my geodatabase file is here https://files.fm/u/q5xuznvy

Code is here

MapView mMapView;

Geodatabase geodatabase; private GeodatabaseFeatureTable geodatabaseFeatureTable; private FeatureLayer featureLayer;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

mMapView = (MapView) findViewById(R.id.map); //Instantiates the MapView object
LoadMap mLoadMap = new LoadMap(); //Runs the LoadMap class on another thread
mLoadMap.execute(); //Calls the background thread

}

private class LoadMap extends AsyncTask {

@Override
protected Void doInBackground(Void... params) {

    try { //Opens up the basemap.geodatabase file from it's location on the physical device
        Log.d("_EXC", "Loading File");
        geodatabase = new Geodatabase("/mnt/shared/Database/mygeodata.gdb");
        Log.d("_EXC", "File Loaded");
    } catch (FileNotFoundException e) {
        Log.d("_EXC", e.getMessage());
    } finally { //Takes each layer one by one from the Geodatabase and adds it to the MapView
        if (geodatabase == null){
            Log.d("_EXC", "File not Loaded");
        }
        for (int i = (geodatabase.getGeodatabaseTables().size()) - 1; i >= 0; i--) {
            geodatabaseFeatureTable = geodatabase.getGeodatabaseFeatureTableByLayerId(i);
            featureLayer = new FeatureLayer(geodatabaseFeatureTable);
            mMapView.addLayer(featureLayer);
        }
    }
    return null;
}

}

1

The issue is with your data format mygeodata.gdb presumably generated with ArcMap. You need to create a *.geodatabase runtime geodatabase file for use with ArcGIS Runtime SDK for Android. Looks like you are using version 10.2.x, below are some relevant references:

  • I created .geodatabase file instead of .gdb. This step geodatabase = new Geodatabase("/mnt/shared/Database/mygeodata.gdb"); how to do if i want to put .geodatabase file in application instead of device? – zohaib Jun 21 '17 at 22:18
  • Putting in app is not directly supported. – jdONeill Nov 4 '17 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.