0
我想打开文件在数据库中使用默认的安卓程序...但我有麻烦打开它... 我存储文件路径在我的数据库(作为字符串),因为它是更好的存储文件路径,而不是自己的文件...(从我读的) ,但是当我想在android中使用默认的android程序打开它时,它什么也不做......只是空白... 我不知道哪部分我错了,因为日志的猫没有表现出什么... 这里是我的代码...打开的文件,其中存储在数据库中使用默认的安卓程序
String fileId = ((TextView)view.findViewById(R.id.fileid)).getText().toString();
String fileName = ((TextView)view.findViewById(R.id.TextView01)).getText().toString();
String filePath = ((TextView)view.findViewById(R.id.filepath)).getText().toString();
//starting activity intent
Intent intent= new Intent();
intent.setAction(Intent.ACTION_VIEW);
File file = new File("http://10.0.2.2/" + filePath);
MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext = file.getName().substring(file.getName().indexOf(".")+1).toLowerCase();
String type = mime.getMimeTypeFromExtension(ext);
intent.setDataAndType(Uri.fromFile(file), type);
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(FileChooser.this, "No Application available to View this file", Toast.LENGTH_SHORT).show();
}
的文件路径就是Android/untitled.jpg 其实我真的很新的开发Android ...我希望任何人都可以帮助我解决我的问题...