Context getFilesDir - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Context getFilesDir method.

This code example shows how to use the following methods:getContentResolver, getFilesDir, openFileOutput, sendBroadcast, sleep
                    "dfrsRsFMrFpk++mSt6SoxXaMbn0LL2u1CD4PCEiQMGt+lK3/3TmRTKNs+23sYS7Ahjxj0udDAkEA" + 
                    "p57Nj65WNaWeYiOfTwKXkLj8l29H5NbaGWxPT0XkWr4PvBOFZVH/wj0/qc3CMVGnv11+DyO+QUCN" + 
                    "SqBB5aRe8g=="; 
 
    private void overrideSettings(String key, String value) throws Exception {
        assertTrue(Settings.Secure.putString(mContext.getContentResolver(), key, value));
        Thread.sleep(1000);
    } 
 
    private void overrideCert(String value) throws Exception {
        overrideSettings(PINLIST_CERTIFICATE_KEY, value);
    } 
 
    private String readPins() throws Exception {
        return IoUtils.readFileAsString(PINLIST_CONTENT_PATH);
    } 
 
    private String readCurrentVersion() throws Exception {
        return IoUtils.readFileAsString("/data/misc/keychain/metadata/version"); 
    } 

9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCacheDir, getFilesDir, getMainLooper
    // Dispatch a round of property updates, should only be called on UI thread 
 
    public static native void pollCourier(); 
 
    public static void init(Context ctx) {
        courier = new Handler(ctx.getMainLooper(), new Handler.Callback() {
                public boolean handleMessage(Message msg) {
                    pollCourier(); 
                    return true; 
                } 
            }); 
 
        coreInit(ctx.getFilesDir().getPath(), ctx.getCacheDir().getPath());
    } 
 
    public static void wakeupMainDispatcher() { 
        courier.sendEmptyMessage(0);
    } 
 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFilesDir, createSpeechRecognizer
    private RecognizerApiListener mListener;
 
    public RecognizerApi(Context context) {
    	this.context = context;
 
    	File dir = context.getFilesDir();
    	aacFile = dir.toString() + "/audio.aac";
 
    	sr = SpeechRecognizer.createSpeechRecognizer(context);
    } 
 
    public void setTemporaryFile(String fileName) {
    	aacFile = context.getFilesDir().toString() + "/" + fileName;
    } 
 
    public String getTemporaryFile() {
    	return aacFile;
    } 
 
    public void setListener(RecognizerApiListener listener) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:fileList, getFilesDir
    assertTrue(context.getFilesDir().exists());
  } 
 
  @Test 
  public void fileList() throws Exception { 
    assertThat(context.fileList()).isEqualTo(context.getFilesDir().list());
  } 
 
  @Test 
  public void getExternalFilesDir_shouldCreateDirectory() throws Exception { 
    assertTrue(context.getExternalFilesDir(null).exists());
  } 
 
  @Test 
  public void getExternalFilesDir_shouldCreateNamedDirectory() throws Exception { 
    File f = context.getExternalFilesDir("__test__");
    assertTrue(f.exists());
    assertTrue(f.getAbsolutePath().endsWith("__test__"));
  } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFilesDir, openFileOutput
This code example shows how to use the following methods:getExternalFilesDir, getFilesDir
    } 
 
    private static String scriptsDirName(Context context) {
        File storageDir = null;
        if (isDebugBuild()) { 
            storageDir = context.getExternalFilesDir(null);
            if (storageDir == null || (!storageDir.exists() && !storageDir.mkdirs())) {
                Log.e("Development mode active, but sdcard is not available.  Make sure you have added\n<uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE' />\nto your AndroidManifest.xml file.");
                storageDir = context.getFilesDir();
            } 
        } else { 
            storageDir = context.getFilesDir();
        } 
        return storageDir.getAbsolutePath() + "/scripts";
    } 
 
    private static void setDebugBuild(Context context) {
        PackageManager pm = context.getPackageManager();
        PackageInfo pi;
        try { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getContentResolver, getFilesDir, openFileOutput, sendBroadcast, sleep
                    "dfrsRsFMrFpk++mSt6SoxXaMbn0LL2u1CD4PCEiQMGt+lK3/3TmRTKNs+23sYS7Ahjxj0udDAkEA" + 
                    "p57Nj65WNaWeYiOfTwKXkLj8l29H5NbaGWxPT0XkWr4PvBOFZVH/wj0/qc3CMVGnv11+DyO+QUCN" + 
                    "SqBB5aRe8g=="; 
 
    private void overrideSettings(String key, String value) throws Exception {
        assertTrue(Settings.Secure.putString(mContext.getContentResolver(), key, value));
        Thread.sleep(1000);
    } 
 
    private void overrideCert(String value) throws Exception {
        overrideSettings(PINLIST_CERTIFICATE_KEY, value);
    } 
 
    private String readPins() throws Exception {
        return IoUtils.readFileAsString(PINLIST_CONTENT_PATH);
    } 
 
    private String readCurrentVersion() throws Exception {
        return IoUtils.readFileAsString("/data/misc/keychain/metadata/version"); 
    } 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCacheDir, getFilesDir
	public static String picPath(String size, int hash, Context context) {
		return picDir(hash, context) + size + ".jpg";
	} 
 
	public static String picDir(int hash, Context context) {
		File cacheDir = context.getCacheDir();
		if (cacheDir == null)
			cacheDir = context.getFilesDir();
		File picDir = new File(context.getCacheDir().getPath() + "/" + hash);
		picDir.mkdirs();
		return picDir.getPath();
	} 
 
	public static void cacheImage(String size, int hash, String url, Context context) {
		File outFile = new File(picPath(size, hash, context));
		if (outFile.exists())
			outFile.delete();
 
		downloadFile(url, outFile);
	} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFilesDir, openFileOutput
     */ 
    private static KeyStore getKnownServersStore(Context context) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
        if (mKnownServersStore == null) {
            //mKnownServersStore = KeyStore.getInstance("BKS"); 
            mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
            File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME);
            Log.d(TAG, "Searching known-servers store at " + localTrustStoreFile.getAbsolutePath());
            if (localTrustStoreFile.exists()) {
                InputStream in = new FileInputStream(localTrustStoreFile);
                try { 
                    mKnownServersStore.load(in, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
                } finally { 
                    in.close();
                } 
            } else { 
                mKnownServersStore.load(null, LOCAL_TRUSTSTORE_PASSWORD.toCharArray()); // necessary to initialize an empty KeyStore instance
            } 
        } 
        return mKnownServersStore;
    } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFilesDir
      } 
    } 
  } 
 
  static File getUpdateBaseDir(Context ctxt) {
    return(new File(ctxt.getFilesDir(), UPDATE_BASEDIR));
  } 
 
  private void checkDownloadInfo(String raw) throws JSONException {
    JSONObject json=new JSONObject(raw);
    String version=json.names().getString(0);
    File localCopy=new File(getUpdateBaseDir(this), version);
 
    if (!localCopy.exists()) {
      PreferenceManager.getDefaultSharedPreferences(this)
                       .edit() 
                       .putString(PREF_PENDING_UPDATE,
                                  localCopy.getAbsolutePath()).commit();
 
      String url=json.getString(version);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Context getFilesDir Questions & Answers:

getFilesDir Method Overview
Returns the absolute path to the directory on the filesystem where files created with openFileOutput(String, int) are stored.
See Code Examples for other Android Context Methods: