android failed to show result -
in following code want crate file in sdcard. not giving valid output. showing hello world...where "file created" message displayed , file stored?
package com.read;  import java.io.fileoutputstream; import android.app.activity; import android.content.context; import android.os.bundle;  public class read extends activity {  /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);       string filename = "hello_file";     string string = "hello world!";     try{     fileoutputstream fos = openfileoutput(filename, context.mode_private);     fos.write(string.getbytes());     fos.close();     }catch(exception e){}      system.out.println("file created");  } } 
using method you're trying create file in phone's internal memory.
just use code:
fileouputstream fos = new fileoutputstream( "/sdcard/" + filename ); it create file in root folder of sd card.
Comments
Post a Comment