本文整理了Java中android.app.Application.getExternalFilesDir()
方法的一些代码示例,展示了Application.getExternalFilesDir()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getExternalFilesDir()
方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:getExternalFilesDir
暂无
代码示例来源:origin: robolectric/robolectric
private static String fixTracePath(String tracePath) {
String defaultTraceBody = "dmtrace";
String defaultTraceExtension = ".trace";
if (tracePath == null || tracePath.charAt(0) != '/') {
final File dir = RuntimeEnvironment.application.getExternalFilesDir(null);
if (tracePath == null) {
tracePath = new File(dir, defaultTraceBody).getAbsolutePath();
} else {
tracePath = new File(dir, tracePath).getAbsolutePath();
}
}
if (!tracePath.endsWith(defaultTraceExtension)) {
tracePath += defaultTraceExtension;
}
return tracePath;
}
}
代码示例来源:origin: roomanl/AndroidDownload
@Override
public File getExternalFilesDir(String type) {
return app.getExternalFilesDir(type);
}
代码示例来源:origin: org.robolectric/shadows-framework
private static String fixTracePath(String tracePath) {
String defaultTraceBody = "dmtrace";
String defaultTraceExtension = ".trace";
if (tracePath == null || tracePath.charAt(0) != '/') {
final File dir = RuntimeEnvironment.application.getExternalFilesDir(null);
if (tracePath == null) {
tracePath = new File(dir, defaultTraceBody).getAbsolutePath();
} else {
tracePath = new File(dir, tracePath).getAbsolutePath();
}
}
if (!tracePath.endsWith(defaultTraceExtension)) {
tracePath += defaultTraceExtension;
}
return tracePath;
}
}
代码示例来源:origin: huangweicai/OkLibDemo
File file = application.getExternalFilesDir(null);
if (!file.exists()) {
file.mkdirs();
file = application.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (!file.exists()) {
file.mkdirs();
file = application.getExternalFilesDir(Environment.DIRECTORY_MUSIC);
if (!file.exists()) {
file.mkdirs();
file = application.getExternalFilesDir(Environment.DIRECTORY_MOVIES);
if (!file.exists()) {
file.mkdirs();
file = application.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
if (!file.exists()) {
file.mkdirs();
代码示例来源:origin: commonsguy/cw-androidarch
private void process(boolean isBackup, int pid) throws IOException {
SystemClock.sleep(1000); // wait for things to settle
Process.killProcess(pid);
File dbDir=getApplication().getDatabasePath("foo").getParentFile();
File extDir=getApplication().getExternalFilesDir(null);
File backupDir=new File(extDir, "db-backup");
if (isBackup) {
if (backupDir.exists()) {
delete(backupDir);
}
backupDir.mkdirs();
copy(dbDir, backupDir);
}
else {
if (dbDir.exists()) {
delete(dbDir);
}
dbDir.mkdirs();
copy(backupDir, dbDir);
}
}
}
代码示例来源:origin: zhangjianli/StallBuster
/**
* name of the directory host all records files
* @return the path
*/
public static String getRecordDirPath() {
if (isExternalStorageWritable()) {
return StallBuster.getInstance().getApp().getExternalFilesDir(null) + "/" + DIR_NAME;
}
return StallBuster.getInstance().getApp().getFilesDir() + "/" + DIR_NAME;
}
内容来源于网络,如有侵权,请联系作者删除!