0

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(); 
    } 
} 
4

1 回答 1

0

您写入文件的内容与屏幕上的内容无关。检查布局 xml (res/layout/main.xml)。(当您调用 时,您正在使用它setContentView(R.layout.main);。)布局可能引用了可以在 res/values/strings.xml 中找到的字符串资源。更改该字符串以更改屏幕上显示的内容。

我建议您阅读适用于 Android 的Hello World 教程来了解这些基础知识。

于 2012-04-22T18:33:12.517 回答