0

I'm trying to display an image, the path of which is stored in a database.

I'm iterating over all locations, and for each I display a marker. There is, however some problem with loading photo by path (line marked).

private void loadLocations() {
    dataSource.open();
    ArrayList <LocationEntry> locations = dataSource.getLocationsFromTrack(trackId);
    dataSource.close();
    for(int i=0; i<locations.size(); i++)
    {
        map.addMarker(new MarkerOptions()
         .position(locations.get(i).getCoordinates())
         .title(locations.get(i).getName())
         .snippet(locations.get(i).getSnippet())    
         .icon(BitmapDescriptorFactory.fromPath(locations.get(i).getPhotoURL()))); //here
    }
}

The photo URL that is handed over to fromPath function looks like this:

'/mnt/sdcard/camtest/26'

I checked this location, and I'm sure that the file of that name exists there. So BitmapDescriptorFactory has problems processing the file path, as it returns null. Any ideas how to solve this? Any alternate ways to get image by its path?

user4359659
  • 149
  • 2
  • 4
  • 18
  • does it work if you try the default marker? also - could it be permission issue [http://stackoverflow.com/questions/8954293/permission-to-read-data-from-sd-card](http://stackoverflow.com/questions/8954293/permission-to-read-data-from-sd-card) – benji Jan 04 '15 at 16:54

1 Answers1

0

Firstly, the image view is not set up that is a reason may be you are getting a Null Pointer Exception. You can try out these two class and method calls they have in order to pass the location of the image stored in SD Card.

Bitmap bm = BitmapFactory.decodeFile("/mnt/sdcard/camtest/26");     
imageView1.setImageBitmap(bm);

and

Drawable d = Drawable.createFromPath(path);

Dont forget the manifest file permissions:

<manifest ...>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
</manifest>
AniV
  • 3,997
  • 1
  • 12
  • 17