I have tried with below code for read and display shapefile from my SD card
<SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">ShapefileFeatureTable</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> shapefileFeatureTable </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">null</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">;</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">try</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">{</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> shapefileFeatureTable </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">new</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">ShapefileFeatureTable</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">Environment</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">getExternalStorageDirectory</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">().</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">getAbsolutePath</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">()+</SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-size: 13px;">"/India_SHP/INDIA.shp"</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">);</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> featureLayer </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">=</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">new</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">FeatureLayer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">shapefileFeatureTable</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">);</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> featureLayer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">setRenderer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">new</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">SimpleRenderer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">new</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">SimpleMarkerSymbol</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> getResources</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">().</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">getColor</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">android</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">R</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">color</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">holo_blue_bright</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">),</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #7d2727; border: 0px; font-size: 13px;">28</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">,</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">SimpleMarkerSymbol</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">STYLE</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">CIRCLE</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">)));</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> mMapView</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">addLayer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">featureLayer</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">);</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">}</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #101094; border: 0px; font-size: 13px;">catch</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">(</SPAN><SPAN class="" style="color: #2b91af; border: 0px; font-size: 13px;">FileNotFoundException</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> e</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">)</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">{</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> e</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">.</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">printStackTrace</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">();</SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;"> </SPAN><SPAN class="" style="color: #303336; border: 0px; font-size: 13px;">} But it returning empty black screen, Can any one help me regarding this?</SPAN>
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 · GitHub .
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" />
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.