title: I get setImageBitmap(Bitmap) in the type ImageView is not applicable for the arguments (byte[])
body: <p>I am getting this error <code>The method setImageBitmap(Bitmap) in the type ImageView is not applicable for the arguments (byte[])</code> when trying to load the image from SQlite database.  </p>
  
  <p>What i did was this</p>
  
  <p>Convert image to byte[]:</p>
  
  <pre><code>baos = new ByteArrayOutputStream();
  bitmap.compress(CompressFormat.JPEG, 100, baos);
  imageData = baos.toByteArray();
  </code></pre>
  
  <p>then save image to Database:</p>
  
  <pre><code>contentValues.put(LocationsDB.FIELD_IMAGE, imageData);
  </code></pre>
  
  <p>Then retrieve image to display in imageview:</p>
  
  <pre><code>byte[] img = null;
  ....
  img = arg1.getBlob(arg1.getColumnIndex(LocationsDB.FIELD_IMAGE));
  ....
  img = markerIcon.setImageBitmap(imageData);
  </code></pre>
  
  <p>But under <code>setImageBitmap</code> i get the error</p>
  
  <p>What do i need to do to resolve this?
  Any help will be greatly appreciated!</p>
  
  <p><strong>EDITED CODE</strong></p>
  
  <pre><code>@Override
  public void onLoadFinished(Loader&lt;Cursor&gt; arg0, Cursor arg1) {
      int locationCount = 0;
      double lat=0;
      double lng=0;
      float zoom=0;
      byte[] img = null;
      locationCount = arg1.getCount();
      arg1.moveToFirst();
  
      for(int i=0;i&lt;locationCount;i++){
  
          lat = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LAT));
          lng = arg1.getDouble(arg1.getColumnIndex(LocationsDB.FIELD_LNG));
          zoom = arg1.getFloat(arg1.getColumnIndex(LocationsDB.FIELD_ZOOM));
          img = arg1.getBlob(arg1.getColumnIndex(LocationsDB.FIELD_IMAGE));
          thePoint = new LatLng(lat, lng);
          drawMarker(thePoint);
          arg1.moveToNext();
      }
  
      if(locationCount&gt;0){
          googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat,lng)));
          googleMap.animateCamera(CameraUpdateFactory.zoomTo(zoom));
          bitmap = BitmapFactory.decodeByteArray(imageData , 0, imageData.length);
          img = markerIcon.setImageBitmap(bitmap);
      }
      }
  </code></pre>
  
  <p><strong>ERROR</strong></p>
  
  <pre><code>12-23 16:39:38.158: E/AndroidRuntime(8168): FATAL EXCEPTION: main
  12-23 16:39:38.158: E/AndroidRuntime(8168): Process: com.example.mainapp, PID: 8168
  12-23 16:39:38.158: E/AndroidRuntime(8168): java.lang.NullPointerException
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at com.example.mainapp.Map.onLoadFinished(Map.java:338)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at com.example.mainapp.Map.onLoadFinished(Map.java:1)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:4    27)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:395)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at  android.support.v4.content.Loader.deliverResult(Loader.java:104)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.CursorLoader.deliverResult(CursorLoader.java:73)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.CursorLoader.deliverResult(CursorLoader.java:35)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:223)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:61)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.ModernAsyncTask.finish(ModernAsyncTask.java:461)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.ModernAsyncTask.access$500(ModernAsyncTask.java:47)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.support.v4.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:474)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.os.Handler.dispatchMessage(Handler.java:102)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.os.Looper.loop(Looper.java:136)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at android.app.ActivityThread.main(ActivityThread.java:5586)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at java.lang.reflect.Method.invoke(Method.java:515)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
  12-23 16:39:38.158: E/AndroidRuntime(8168):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>