how to read file from the phone memory in android? -


i need read file phone memory.how read file ?can me??

here's how write in file..

fileoutputstream fos = openfileoutput("urls.txt", context.mode_private); fos.write("alex".getbytes()); fos.close(); 

here's how read file:

fileinputstream fis = openfileinput("urls.txt"); int c; while((c=fis.read())!=-1)         {              k += (char)c;         } fis.close(); 

string k contain "ankit" string.

mind you.. file "urls.txt" gets formed in phone memory, cannot access file in project resource.

for more information see: http://developer.android.com/guide/topics/data/data-storage.html#filesinternal


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -