I'm trying to use ArcGIS
to draw some shape file on the map using its ShapefileFeatureTable
. But when I try the load the shape file I get a File not found
Exception.
This is the code I'm using:
ShapefileFeatureTable shapefileFeatureTable;
try {
shapefileFeatureTable = new ShapefileFeatureTable(Environment.getExternalStorageDirectory().getAbsolutePath() + "/shape.shp");
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "loading shape failed", Toast.LENGTH_SHORT).show();
return;
}
The catch here is that the shape file actually exists on the sdcard. I debugged the code and reached this part which is throwing the exception:
static Geodatabase a(String var0) throws FileNotFoundException {
File var1 = new File(var0);
if(!var1.exists()) {
throw new FileNotFoundException(var1 + " does not exist.");
} else {
return new Geodatabase(nativeOpenShapefile(var0)); // this is where it happens
}
}
The native nativeOpenShapefile
seems to not be able to see the file while the java part perfectly sees it. Check the stacktrace:
D/dalvikvm: Trying to load lib /data/data/com.hmomeni.arcgis/lib/libruntimecore_java.so 0x4163daf0 D/dalvikvm: Added shared lib /data/data/com.hmomeni.arcgis/lib/libruntimecore_java.so 0x4163daf0 W/System.err: java.lang.RuntimeException: Shape file not found: /storage/sdcard0/shape.shp W/System.err: at com.esri.core.geodatabase.Geodatabase.nativeOpenShapefile(Native Method) W/System.err: at com.esri.core.geodatabase.Geodatabase.a(SourceFile:126) W/System.err: at com.esri.core.geodatabase.ShapefileFeatureTable.(SourceFile:79) W/System.err: at com.hmomeni.arcgis.MainActivity.initView(MainActivity.java:32) W/System.err: at com.hmomeni.arcgis.MainActivity.onCreate(MainActivity.java:21) W/System.err: at android.app.Activity.performCreate(Activity.java:5031) W/System.err:
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1082) W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2038) W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2099) W/System.err: at android.app.ActivityThread.access$600(ActivityThread.java:134) W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) W/System.err: at android.os.Handler.dispatchMessage(Handler.java:99) W/System.err:
at android.os.Looper.loop(Looper.java:137) W/System.err: at android.app.ActivityThread.main(ActivityThread.java:4797) W/System.err: at java.lang.reflect.Method.invokeNative(Native Method) W/System.err: at java.lang.reflect.Method.invoke(Method.java:511) W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:776) W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:543) W/System.err: at dalvik.system.NativeStart.main(Native Method)
I wonder what could be the problem?