android 6.0 ,open .geodatabase file err

3606
4
06-03-2016 01:37 AM
dgterydgt
New Contributor

after android runtime update,tip java.lang.RuntimeException: Unable to open the database file

0 Kudos
4 Replies
AlexanderNohe1
Occasional Contributor III

You need to enable runtime permissions for access to external storage at Android API 23.  If you are compiling/deploying to API 22 or below this is not required.  See the following help documentation:

Requesting Permissions at Run Time | Android Developers

0 Kudos
by Anonymous User
Not applicable

I don't know if this helps but I am noticing in Android M (6.0) when pointed at SD Card that some environmental variables no longer work even with permissions setup correctly.  For example I had to change the following...(there are probably other ways to do this also).

System.getenv("SECONDARY_STORAGE")

to a little more convoluted method to get SD Card path...

if (Build.VERSION.SDK_INT >= 23) {

   for (File file : mContext.getExternalFilesDirs(null)) {

       if (file.getPath().contains("emulate")) {

       }else{

              File fileParent = file.getParentFile();

              appSDPath = fileParent.getPath() + "/Reference_Data";

              appSDPathApplication = fileParent.getPath();

       }

  }

}else{

   appSDPath = System.getenv("SECONDARY_STORAGE") + "/Android/data/com.company.app/Reference_Data";

}

AlexanderNohe1
Occasional Contributor III

dgtery dgt​,

Did the above suggestions help?  Are you still having issues?

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi dgtery dgt​,

Make sure you enable the permission in your AndroidManifest.xml, you probably not give the WRITE & READ permission.

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

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

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

Install and set up—ArcGIS Runtime SDK for Android | ArcGIS for Developers

Hope this can help.