I am making an app which creates a floder. In that folder it I am creating a file and writing Radha in it. but it shows Hello World, CreateActivity the code is
Create.java
public class CreateActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Context ctx = getApplicationContext();
try {
File myDir = new File(getFilesDir().getAbsolutePath());
String s = "";
FileWriter fw = new FileWriter(myDir + "/Test.txt");
fw.write("Radha");
fw.close();
BufferedReader br = new BufferedReader(new FileReader(myDir + "/Test.txt"));
s = br.readLine();
// Set TextView text here using tv.setText(s);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
What you write into the file has nothing to do with what's on the screen. Check the layout xml (res/layout/main.xml). (You are using this when you call setContentView(R.layout.main);
.) The layout probably references a string resource that can be found in res/values/strings.xml. Change that string to change what's displayed on the screen.
I suggest that you go through the Hello World tutorial for Android to gain an understanding of these fundamentals.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.