how can I open a file that has been previously stored in the "privat" filesystem? The file is being downloaded by a webservice and should be stored on local fs. I got a "strange" error when trying to open the file via an Intent (Action_View). Although the file is present in the filesystem (saw the file in the file explorer in emulator/eclipse) it won't be shown in the calling galery activity that is launched. Instead of the picture the galery shows a black screen with not content in there (except the action bar). The same occurs when trying to open a pdf/movie/mp3 file via this method (pdf says for example that the file is corrupt).
BTW: The data that has been stored on the local fs is valid (not corrupt), I downloaded the files from debugger (via pull method) and the files can be opened on my workstation...
public void onAttachment(Context context, Attachment attachment) {
try {
//Attachment is a structured data object that contains of a byte[], filename and mimetype (like image/jpeg)
FileOutputStream fos = FileOutputStream fos = context.openFileOutput(attachment.getAttachmentFileName(), Context.MODE_PRIVATE);
fos.write(attachment.getBinary());
fos.flush();
fos.close();
File f = context.getFileStreamPath(attachment.getAttachmentFileName());
Uri uri = Uri.fromFile(f);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri,attachment.getAttachmentMimetype());
context.startActivity(intent);
} catch (IOException e) {
e.printStackTrace();
}
}