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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -