Java tutorial
//package com.java2s; import android.content.Context; import android.os.Build; import java.io.File; public class Main { private static String databaseFolder = null; public static String getExternalRootDirectory(Context context) { if (databaseFolder == null) { //The location of the temp internal database used for sync should be //in the cache, since it is only needed for <1min at a time, and //created every time it is needed if (useSAF()) { File basePath = new File( context.getCacheDir() + File.separator + "externalDatabaseSync" + File.separator); databaseFolder = basePath.getPath(); } else { return "/storage/usbdisk0/WildRank/cblite"; } } return databaseFolder; } public static boolean useSAF() { return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; } }