Neufman Neufman - 1 year ago 68
Android Question

Launching an intent for file : "Unable to find item"

I wish I could open any file type using mobile applications.

Here is the code :

File mFile = new File( file.getLocalPath() + file.getFileName() );
Log.i("path", file.getLocalPath() + file.getFileName());

if( mFile.exists() )
MimeTypeMap map = MimeTypeMap.getSingleton();
String ext = MimeTypeMap.getFileExtensionFromUrl(mFile.getName());
String type = map.getMimeTypeFromExtension(ext);

if (type == null)
type = "*/*";

Log.i("type", type);

Intent intent = new Intent();
Uri data = Uri.fromFile(mFile);
Log.i("uri", data.toString());
intent.setDataAndType( data, type );

try {
} catch (android.content.ActivityNotFoundException e) {

Logs :

  • Path :

  • Type :

  • Uri :

All logs are displayed therefore the file exists.
However, during the opening of the gallery, I get an
"Unable to find item"

Where is the problem ? Are there other solutions ?

Answer Source

The problem is that you are trying to open file which is in android private area thats why during the opening of the gallery, you get an "Unable to find item". You have to put your file in local. If you want to open a file of android private area you should be rooted.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download