question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot display some local files with a space in their name

See original GitHub issue

I’m loading images from the local storage using the following code:

if (file.exists() && ContentType.isImage(file)) {
    final String uri = Uri.fromFile(file).toString();
    ImageLoader.getInstance().displayImage(uri, imageView);
}

This fails with the following exception:

/storage/emulated/0/.../ad%20(1).jpg: open failed: ENOENT (No such file or directory)
java.io.FileNotFoundException: /storage/emulated/0/.../ad%20(1).jpg: open failed: ENOENT (No such file or directory)

// path manually truncated, due to length

It looks like the file name extracted from the URL does not decode the %20 to " ".

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
Dcodechefcommented, Aug 27, 2013

Hey, Just solved the issue. After getting uri using: Uri fileUri=Uri.fromfile(fileObject);

USE: setUrl(Uri.decode(fileUri));

Cheers!

0reactions
wangduanqing5945commented, Aug 10, 2016

I have same problem when path contains chinese.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to start/open a file/folder that contains space in its name ...
I'm trying to use the start command in the command prompt to open files and folders, but I'm unable to open files and...
Read more >
Cannot link to local files with spaces in filename #2539 - GitHub
As a workaround, try escaping your spaces: [example](file\ with\ spaces.md) . This is non-standard and doesn't work on GitHub's markdown, but it ...
Read more >
Naming Files, Paths, and Namespaces - Win32 apps
The backslash divides the file name from the path to it, and one directory name from another directory name in a path. You...
Read more >
How do I specify C:\Program Files without a space in it for ...
User this command: mklink /D "C:\LinkToProgramFiles" "C:\Program Files". And then, you start using "C:\LinkToProgramFiles" in the applications that can't handle ...
Read more >
530064 - Firefox can't open local files (from Finder) with space ...
Bingo! Its the space character in the file name! Take out the space and it opens OK. Put a space into a file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found