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
Post a Comment