How to display a map using shape files in Android?

1696
2
12-02-2016 01:29 AM
PeddirajuGinnedumu
New Contributor

I have tried with below code for read and display shapefile from my SD card

    ShapefileFeatureTable shapefileFeatureTable = null;    try {        shapefileFeatureTable = new ShapefileFeatureTable(Environment.getExternalStorageDirectory().getAbsolutePath()+"/India_SHP/INDIA.shp");        featureLayer = new FeatureLayer(shapefileFeatureTable);        featureLayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol(                getResources().getColor(android.R.color.holo_blue_bright),                28, SimpleMarkerSymbol.STYLE.CIRCLE)));         mMapView.addLayer(featureLayer);     } catch (FileNotFoundException e) {        e.printStackTrace();    }

But it returning empty black screen, Can any one help me regarding this?

Tags (3)
0 Kudos
2 Replies
EricBader
Occasional Contributor III

I see this happen sometimes when my app hasn't been granted external storage permissions. Does you manifest file have the following entry?

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

ShellyGill1
Esri Contributor

Good point Eric, it's easy to get caught by this. Also, if you're working on Android Marshmallow or up, then these permissions will not automatically be granted at install time - so add code to check, then ask for permission when you run the app, and allow the user to agree or disagree - you can see an example of this in this sample on GitHub: arcgis-runtime-samples-android/MainActivity.java at master · Esri/arcgis-runtime-samples-android · G... .