I downloaded the file from HttpConnectionusing FileOutputStreamin android and now it is being written to the phone’s internal memory along the way since I found it inFile Explorer
/data/data/com.example.packagename/files/123.ics
Now I want to open and read the contents of the file from the phone’s internal memory to the user interface. I tried to do this with FileInputStream, I just gave the name of the file with the extension to open it, but I'm not sure how to specify the path to the file in the internal memory, as it causes the application to close.
Any suggestions?
This is what I do:
try
{
FileInputStream fileIn;
fileIn = openFileInput("123.ics");
InputStream in = null;
EditText Userid = (EditText) findViewById(R.id.user_id);
byte[] buffer = new byte[1024];
int len = 0;
while ( (len = in.read(buffer)) > 0 )
{
Userid.setText(fileIn.read(buffer, 0, len));
}
fileIn.close();
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
source
share