android.app.Application.getExternalFilesDir()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中android.app.Application.getExternalFilesDir()方法的一些代码示例,展示了Application.getExternalFilesDir()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getExternalFilesDir()方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:getExternalFilesDir

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;
}

相关文章

微信公众号

最新文章

更多

Application类方法