This source file includes following definitions.
- setPrivateDataDirectorySuffix
- getDataDirectory
- getDatabaseDirectory
- SuppressWarnings
- getCacheDirectory
- SuppressWarnings
- getDownloadsDirectory
- SuppressWarnings
- getNativeLibraryDirectory
- SuppressWarnings
- getExternalStorageDirectory
package org.chromium.base;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Environment;
public abstract class PathUtils {
private static String sDataDirectorySuffix;
private PathUtils() {}
public static void setPrivateDataDirectorySuffix(String suffix) {
sDataDirectorySuffix = suffix;
}
@CalledByNative
public static String getDataDirectory(Context appContext) {
if (sDataDirectorySuffix == null) {
throw new IllegalStateException(
"setDataDirectorySuffix must be called before getDataDirectory");
}
return appContext.getDir(sDataDirectorySuffix, Context.MODE_PRIVATE).getPath();
}
@CalledByNative
public static String getDatabaseDirectory(Context appContext) {
return appContext.getDatabasePath("foo").getParent();
}
@SuppressWarnings("unused")
@CalledByNative
public static String getCacheDirectory(Context appContext) {
return appContext.getCacheDir().getPath();
}
@SuppressWarnings("unused")
@CalledByNative
private static String getDownloadsDirectory(Context appContext) {
return Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS).getPath();
}
@SuppressWarnings("unused")
@CalledByNative
private static String getNativeLibraryDirectory(Context appContext) {
ApplicationInfo ai = appContext.getApplicationInfo();
if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0 ||
(ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
return ai.nativeLibraryDir;
}
return "/system/lib/";
}
@SuppressWarnings("unused")
@CalledByNative
public static String getExternalStorageDirectory() {
return Environment.getExternalStorageDirectory().getAbsolutePath();
}
}