Last active
August 29, 2015 14:22
-
-
Save zafe/dfd6a8d0101fc7e3307e to your computer and use it in GitHub Desktop.
Write a file in android using FileWriter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.paad.comparison; | |
import java.io.FileOutputStream; | |
import java.io.FileWriter; | |
import android.app.Activity; | |
import android.os.Bundle; | |
public class ComparisonOfControlCreationActivity extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
String string1 = "Hey you"; | |
FileOutputStream fos ; | |
try { | |
fos = new FileOutputStream("/sdcard/filename.txt", true); | |
FileWriter fWriter; | |
try { | |
fWriter = new FileWriter(fos.getFD()); | |
fWriter.write("hi"); | |
fWriter.close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
fos.getFD().sync(); | |
fos.close(); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment