Context deleteFile - 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 deleteFile method.

This code example shows how to use the following methods:deleteFile, getFilesDir
    } 
  } 
 
  @Test 
  public void deleteFile_shouldReturnTrue() throws IOException { 
    File filesDir = context.getFilesDir();
    File file = new File(filesDir, "test.txt");
    boolean successfully = file.createNewFile();
    assertThat(successfully).isTrue();
    successfully = context.deleteFile(file.getName());
    assertThat(successfully).isTrue();
  } 
 
  @Test 
  public void deleteFile_shouldReturnFalse() throws IOException { 
    File filesDir = context.getFilesDir();
    File file = new File(filesDir, "test.txt");
    boolean successfully = context.deleteFile(file.getName());
    assertThat(successfully).isFalse();
  } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:deleteFile, getDefaultSharedPreferences
	} 
 
	public void remove() { 
		String storageMode = getStorageMode();
		if (storageMode.equals("internal") || storageMode.equals("")) {
			context.deleteFile(this.fileName);
		} else if (storageMode.equals("sdcard")) {
			File root = Environment.getExternalStorageDirectory();
			File morgDir = new File(root, "mobileorg");
			File morgFile = new File(morgDir, this.fileName);
			morgFile.delete();
		} 
	} 
 
	private String getStorageMode() {
		return PreferenceManager.getDefaultSharedPreferences(this.context)
				.getString("storageMode", "");
	} 
	 
	private String getSynchMode() {
		return PreferenceManager.getDefaultSharedPreferences(this.context)
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Context deleteFile Questions & Answers:

deleteFile Method Overview
Delete the given private file associated with this Context's application package.
See Code Examples for other Android Context Methods: