This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Android and the fly likes getting real path from an image uri after camera and uploading-getting null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "getting real path from an image uri after camera and uploading-getting null pointer exception" Watch "getting real path from an image uri after camera and uploading-getting null pointer exception" New topic
Author

getting real path from an image uri after camera and uploading-getting null pointer exception

rod manssou
Greenhorn

Joined: May 03, 2012
Posts: 3
I have an app that is just a webview with a button overlayed(shows up onyl in certain situations. it opens the camera, takes the picture an saves it BUT only if i comment out the whole ftp part(the real issue is i am getting a nullpointer exception in getrealpathfromuri). but WHY! I have the real path being output to logcat and its fine.

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Welcome to JavaRanch!

You say you're getting a NullPointerException, but where exactly? Could you post the stack trace?
rod manssou
Greenhorn

Joined: May 03, 2012
Posts: 3
Greg Charles wrote:Welcome to JavaRanch!

You say you're getting a NullPointerException, but where exactly? Could you post the stack trace?


Hi! Thanks for the greeting! I am getting the NPE in the getRealPathFromURI(uri) method. But i do not know why. logcat shows the output of System.out.prinln(picUri) as file:///mnt/sdcard/xxx.jpg (even though there is no sdcard and it ends up in the root directory which is fine).
but when i call getRealPathFromUri(picUri) I get a NPE at "int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);"
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

OK, that's not a stack trace, but at least you narrow it down to the line that's causing the problem. So either cursor is null, or the NPE comes from the method getColumnIndexOrThrow(). Can you check if cursor is null? Or just post a stack trace.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Don't ever do this:

catch (IOException e)
{
}

You simply must handle I/O exceptions, you can't just proceed as if nothing has happened. You should also log the exception message.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting real path from an image uri after camera and uploading-getting null pointer exception
 
Similar Threads
how to get progress bar after selecting a view
how to send multiple images to server
how to transfer images to ftp server in android
how to create sdcard and mount on the emulator
Camera failed error