我已经从HttpConnection
使用FileOutputStream
in android下载了一个文件,现在它被写入手机的内存路径中,因为我在File Explorer
/data/data/com.example.packagename/files/123.ics
现在,我想打开并从手机内存读取文件内容到 UI。我试图通过使用来做到这一点FileInputStream
,我只给出了带有扩展名的文件名来打开它,但我不确定如何提及内部存储器中文件的文件路径,因为它会强制应用程序关闭。
有什么建议么?
这就是我正在做的事情:
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();
}