Tabnine Logo
Context.getExternalFilesDir
Code IndexAdd Tabnine to your IDE (free)

How to use
getExternalFilesDir
method
in
android.content.Context

Best Java code snippets using android.content.Context.getExternalFilesDir (Showing top 20 results out of 1,188)

origin: k9mail/k-9

@Override
public void init(Context context) {
  mApplicationDirectory = context.getExternalFilesDir(null);
}
origin: oasisfeng/condom

@Override public File getExternalFilesDir(String type) {
  return mBase.getExternalFilesDir(type);
}
origin: TeamNewPipe/NewPipe

private static File getPendingDir(@NonNull Context context) {
  //File dir = new File(ContextCompat.getDataDir(context), "pending_downloads");
  File dir = context.getExternalFilesDir("pending_downloads");
  if (dir == null) {
    // One of the following paths are not accessible ¿unmounted internal memory?
    //        /storage/emulated/0/Android/data/org.schabi.newpipe[.debug]/pending_downloads
    //        /sdcard/Android/data/org.schabi.newpipe[.debug]/pending_downloads
    Log.w(TAG, "path to pending downloads are not accessible");
  }
  return dir;
}
origin: ACRA/acra

  @NonNull
  @Override
  public File getFile(@NonNull Context context, @NonNull String fileName) {
    return new File(context.getExternalFilesDir(null), fileName);
  }
},
origin: czy1121/update

public static void ensureExternalCacheDir(Context context) {
  File file = context.getExternalCacheDir();
  if (file == null) {
    file = new File(context.getExternalFilesDir("").getParentFile(), "cache");
  }
  if (file != null) {
    file.mkdirs();
  }
}
origin: commonsguy/cw-omnibus

RecordingSession(Context ctxt, RecordingConfig config,
         MediaProjection projection) {
 this.ctxt=ctxt.getApplicationContext();
 this.config=config;
 this.projection=projection;
 this.beeper=new ToneGenerator(
  AudioManager.STREAM_NOTIFICATION, 100);
 output=new File(ctxt.getExternalFilesDir(null), "andcorder.mp4");
 output.getParentFile().mkdirs();
}
origin: commonsguy/cw-omnibus

@Override
public Fragment getItem(int position) {
 File fileToEdit;
 switch(position) {
  case TAB_INTERNAL:
   fileToEdit=new File(ctxt.getFilesDir(), FILENAME);
   break;
  case TAB_EXTERNAL:
   fileToEdit=new File(ctxt.getExternalFilesDir(null), FILENAME);
   break;
  default:
   fileToEdit=
     new File(Environment.
        getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
       FILENAME);
   break;
 }
 return(EditorFragment.newInstance(fileToEdit));
}
origin: commonsguy/cw-omnibus

@Override
public Fragment getItem(int position) {
 File fileToEdit;
 switch(position) {
  case TAB_INTERNAL:
   fileToEdit=new File(ctxt.getFilesDir(), FILENAME);
   break;
  case TAB_EXTERNAL:
   fileToEdit=new File(ctxt.getExternalFilesDir(null), FILENAME);
   break;
  default:
   fileToEdit=
     new File(Environment.
        getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
       FILENAME);
   break;
 }
 return(EditorFragment.newInstance(fileToEdit));
}
origin: commonsguy/cw-omnibus

@Override
public Fragment getItem(int position) {
 File fileToEdit;
 switch(position) {
  case TAB_INTERNAL:
   fileToEdit=new File(ctxt.getFilesDir(), FILENAME);
   break;
  case TAB_EXTERNAL:
   fileToEdit=new File(ctxt.getExternalFilesDir(null), FILENAME);
   break;
  default:
   fileToEdit=
     new File(Environment.
        getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS),
       FILENAME);
   break;
 }
 return(EditorFragment.newInstance(fileToEdit));
}
origin: jgilfelt/chuck

private static String extractDatabase(Context context) {
  try {
    File external = context.getExternalFilesDir(null);
    File data = Environment.getDataDirectory();
    if (external != null && external.canWrite()) {
      String dataDBPath = "data/" + context.getPackageName() + "/databases/chuck.db";
      String extractDBPath = "chuckdb.temp";
      File dataDB = new File(data, dataDBPath);
      File extractDB = new File(external, extractDBPath);
      if (dataDB.exists()) {
        FileChannel in = new FileInputStream(dataDB).getChannel();
        FileChannel out = new FileOutputStream(extractDB).getChannel();
        out.transferFrom(in, 0, in.size());
        in.close();
        out.close();
        return extractDB.getAbsolutePath();
      }
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}
origin: jMonkeyEngine/jmonkeyengine

logger.log(Level.FINE, "ExternalStorageState: {0}", state);
if (state.equals(Environment.MEDIA_MOUNTED)) {
  storageFolder = view.getContext().getExternalFilesDir(null);
  storageFolders.put(type, storageFolder);
origin: gzu-liyujiang/AndroidPicker

/**
 * 各种类型的文件的专用的保存路径,以“/”结尾
 *
 * @return 诸如:/mnt/sdcard/Android/data/[package]/files/[type]/
 */
public static String getExternalPrivatePath(Context context, String type) {
  File file = null;
  if (externalMounted()) {
    file = context.getExternalFilesDir(type);
  }
  //高频触发java.lang.NullPointerException,是SD卡不可用或暂时繁忙么?
  String path = "";
  if (file != null) {
    path = FileUtils.separator(file.getAbsolutePath());
  }
  LogUtils.verbose("external storage private path: " + path);
  return path;
}
origin: robolectric/robolectric

@Test
public void getExternalFilesDir_shouldCreateDirectory() throws Exception {
 assertThat(context.getExternalFilesDir(null).exists()).isTrue();
}
origin: robolectric/robolectric

@Test
public void getExternalFilesDir_shouldCreateNamedDirectory() throws Exception {
 File f = context.getExternalFilesDir("__test__");
 assertThat(f.exists()).isTrue();
 assertThat(f.getAbsolutePath()).endsWith("__test__");
}
origin: LitePalFramework/LitePal

String path = LitePalApplication.getContext().getExternalFilesDir("") + "/databases/";
dbFile = new File(path + dbName);
boolean result = dbFile.delete();
origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void startStopTracingSamplingShouldWriteFile() {
 Debug.startMethodTracingSampling(TRACE_FILENAME, 100, 100);
 Debug.stopMethodTracing();
 assertThat(new File(context.getExternalFilesDir(null), TRACE_FILENAME).exists()).isTrue();
}
origin: robolectric/robolectric

@Test
public void startStopTracingShouldWriteFile() {
 Debug.startMethodTracing(TRACE_FILENAME);
 Debug.stopMethodTracing();
 assertThat(new File(context.getExternalFilesDir(null), TRACE_FILENAME).exists()).isTrue();
}
origin: LitePalFramework/LitePal

String dbName = litePalAttr.getDbName();
if ("external".equalsIgnoreCase(litePalAttr.getStorage())) {
  dbName = LitePalApplication.getContext().getExternalFilesDir("") + "/databases/" + dbName;
} else if (!"internal".equalsIgnoreCase(litePalAttr.getStorage()) && !TextUtils.isEmpty(litePalAttr.getStorage())) {
origin: DaxiaK/MyDiary

/**
 * Create diary  dir file manager
 */
public FileManager(Context context, long topicId, long diaryId) {
  this.mContext = context;
  this.fileDir = mContext.getExternalFilesDir(DIARY_ROOT_DIR_STR + "/" + topicId + "/" + diaryId + "/");
}
origin: GcsSloop/diycode

/**
 * @param context    上下文
 * @param customPath 自定义路径
 * @return 内存卡文件目录
 */
public static String getExternalFileDir(Context context, String customPath) {
  String path = context.getExternalFilesDir("") + formatPath(customPath);
  mkdir(path);
  return path;
}
android.contentContextgetExternalFilesDir

Popular methods of Context

  • getPackageName
  • getResources
  • getSystemService
  • obtainStyledAttributes
  • getApplicationContext
  • getString
  • getPackageManager
  • startActivity
  • getContentResolver
  • getSharedPreferences
  • getAssets
  • getTheme
  • getAssets,
  • getTheme,
  • getCacheDir,
  • startService,
  • sendBroadcast,
  • getFilesDir,
  • registerReceiver,
  • getApplicationInfo,
  • unregisterReceiver,
  • getExternalCacheDir

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • setScale (BigDecimal)
  • setRequestProperty (URLConnection)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now