Context openFileOutput - 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 openFileOutput 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:openFileOutput, getDefaultSharedPreferences
8
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: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: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:openFileOutput
 
  @Test(expected = IllegalArgumentException.class) 
  public void openFileOutput_shouldNotAcceptPathsWithSeparatorCharacters() throws Exception { 
    FileOutputStream fos = null;
    try { 
      fos = context.openFileOutput(File.separator + "data" + File.separator + "test" + File.separator + "hi", 0);
    } finally { 
      if (fos != null)
        fos.close();
    } 
  } 
 
  @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();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:openFileOutput
	{  
		if( content == null )	content = "";
		 
		try  
		{ 
			FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
			fos.write( content.getBytes() ); 
			 
			fos.close();
		} 
		catch (Exception e) 
		{ 
			e.printStackTrace();
		}  
	} 
	 
	/** 
	 * 读取文本文件 
	 * @param context 
	 * @param fileName 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:openFileOutput
	} 
	public static void saveImage(Context context, String fileName, Bitmap bitmap, int quality) throws IOException 
	{  
		if(bitmap==null || fileName==null || context==null)	return;		
 
		FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		bitmap.compress(CompressFormat.JPEG, quality, stream);
		byte[] bytes = stream.toByteArray();
		fos.write(bytes); 			
		fos.close();
	} 
	 
	/** 
	 * 写图片文件到SD卡 
	 * @throws IOException  
	 */ 
	public static void saveImageToSD(String filePath, Bitmap bitmap, int quality) throws IOException
	{ 
		if(bitmap != null) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Context openFileOutput Questions & Answers:

openFileOutput Method Overview
Open a private file associated with this Context's application package for writing.
See Code Examples for other Android Context Methods: