I am trying to open a local file in Android (4.0) using intents. The following is the code to do the action. This works fine as long as the file has no special spaces (For example: if the file is /data/data/com.xxxx.yyyy/files/Downloads/Documents/ProductFeature.pptx, the it opens fine, but if the file name is /data/data/com.xxxx.yyyy/files/Downloads/Documents/Product Feature.pptx (note the space in name), then it fails. The Uri.fromFile encodes the space correctly, but the other apps cant seem to interpret them and seem fail opening.
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File( selectedEntry.get(Defs.PATH_KEY)));
System.out.println("openFileWith: File to open: " + uri);
intent.setDataAndType(uri,type);
startActivity(Intent.createChooser(intent, "Open With ..."));
I also tried to use "file://" + unencoded path without much help.
So how do you handle this condition? Any help is appreciated