title: Album photos not shown
body: <p>I would love to display the pictures in my app album into a recycler view with view holder,but after I tried the tutorials and compile it. There is no error but neither photos display in my app.</p>
  
  <p><strong>Still facing the same issue and I have updated my current code</strong></p>
  
  <p><strong>UPDATED ON 30-01-17</strong></p>
  
  <p>Below are the codes:</p>
  
  <p><strong>Album.java</strong></p>
  
  <pre><code>public class Album extends Fragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.album, container, false);
  
  
      RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.albumView);
      recyclerView.setHasFixedSize(true);
      RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
      recyclerView.setLayoutManager(layoutManager);
  
      ArrayList&lt;CreateList&gt; createLists = prepareData();
      AlbumAdpater adapter = new AlbumAdpater(getContext(), createLists);
      recyclerView.setAdapter(adapter);
  
      return view;
  }
  
  
  private ArrayList&lt;CreateList&gt; prepareData() {
  
      ArrayList&lt;CreateList&gt; theimage = new ArrayList&lt;&gt;();
      String path = Environment.getExternalStoragePublicDirectory(
              Environment.DIRECTORY_PICTURES).toString();
      File files = new File(path);
      File file[] = files.listFiles();
      Log.e("Album","PrepareData");
      for (int i = 0; i &lt; file.length; i++) {
          CreateList createList = new CreateList();
          createList.setImage_location(file[i].getAbsolutePath());
          createList.setImage_title(file[i].getName());
          theimage.add(createList);
      }
      return theimage;
  }
   public void reprmission() {if (ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.READ_CONTACTS)
              != PackageManager.PERMISSION_GRANTED);
      {
          if (ActivityCompat.shouldShowRequestPermissionRationale(
                  getActivity(), android.Manifest.permission.READ_EXTERNAL_STORAGE)){
          } else {
  
          ActivityCompat.requestPermissions(getActivity(), new String[]
                  {Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_CODE_ASK_PERMISSION);
      }
      } return;
  }
  }
  </code></pre>
  
  <p><strong>Createlist.java</strong></p>
  
  <pre><code>public class CreateList  {
  
  private String image_title;
  private Integer image_id;
  private String image_location;
  
  public String getImage_location() {
      return image_location;
  }
  
  public void setImage_location(String image_location) {
      this.image_location = image_location;
  }
  
  
  public String getImage_title() {
      return image_title;
  }
  
  public void setImage_title(String android_version_name) {
      this.image_title = android_version_name;
  }
  
  public Integer getImage_ID() {
      return image_id;
  }
  
  public void setImage_ID(Integer android_image_url) {
      this.image_id = android_image_url;
  }
  }
  </code></pre>
  
  <p><strong>AlbumAdapter.java</strong></p>
  
  <pre><code>public class AlbumAdpater extends RecyclerView.Adapter&lt;AlbumAdpater.ViewHolder&gt; {
  
  private ArrayList&lt;CreateList&gt; galleryList;
  private Context context;
  
  public AlbumAdpater(Context context, ArrayList&lt;CreateList&gt; galleryList){
      this.galleryList= galleryList;
      this.context = context;
  }
  
  @Override
  public AlbumAdpater.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i){
      View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.cell_layout, viewGroup, false);
      return new ViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(AlbumAdpater.ViewHolder viewHolder, int i){
    //  viewHolder.title.setText(galleryList.get(i).getImage_title());
      viewHolder.img.setScaleType(ImageView.ScaleType.CENTER_CROP);
   //   viewHolder.img.setImageResource((galleryList.get(i).getImage_ID()));
      setImage(galleryList.get(i).getImage_location(),viewHolder.img);
      Picasso.with(context).load(galleryList.get(i).getImage_location()).resize(50,50).centerCrop().into(viewHolder.img);
  }
  
  @Override
  public int getItemCount(){
      return galleryList.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder{
  
      private TextView title;
      private ImageView img;
  
      public ViewHolder(View view){
          super(view);
          title = (TextView) view.findViewById(R.id.imgtitle);
          img = (ImageView) view.findViewById(R.id.img);
      }
  }
  
  void setImage(String filePath, ImageView imageView){
  Picasso.with(context).load(new File(filePath)).into(imageView);
  }
  }
  </code></pre>
  
  <p><strong>Logcat report</strong></p>
  
  <pre><code>  Reconstruct Branch               : 
     01-30 13:31:54.924 8612-8701/com.example.kaiser.bdiary I/OpenGLRenderer: Initialized EGL, version 1.4
   01-30 13:31:54.941 8612-8612/com.example.kaiser.bdiary W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
   01-30 13:31:54.951 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:31:54.952 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:31:54.954 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:31:54.956 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:31:54.957 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:31:54.958 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:32:23.922 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b911fe5
   01-30 13:32:23.979 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@adce0c8
   01-30 13:33:41.293 8612-8695/com.example.kaiser.bdiary W/System: ClassLoader referenced unknown path: /data/data/com.example.kaiser.bdiary/lib
   01-30 13:33:41.349 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@d54d109
   01-30 13:33:41.350 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf =           com.qualcomm.qti.Performance@ac3ef0e
   01-30 13:33:41.350 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b173d2f
   01-30 13:33:41.387 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@7a4e0bc
   01-30 13:33:41.387 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b152845
   01-30 13:33:41.390 8612-8612/com.example.kaiser.bdiary E/Album: PrepareData
   01-30 13:33:41.393 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@3d4ca8
   01-30 13:33:41.535 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.536 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.538 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.543 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.545 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.547 8612-8612/com.example.kaiser.bdiary E/Album: onBindViewHolder
   01-30 13:33:41.579 8612-8701/com.example.kaiser.bdiary V/RenderScript:      0x7f819bb000 Launching thread(s), CPUs 4
   01-30 13:33:50.192 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fcf2205
   01-30 13:33:50.916 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b720c8b
   01-30 13:33:53.217 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@724d981
   01-30 13:33:54.881 8612-8612/com.example.kaiser.bdiary V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fbc1a26
  </code></pre>
  
  <p><strong>RecycleView</strong> </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&lt;android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/albumView"&gt;
   &lt;/android.support.v7.widget.RecyclerView&gt;
  </code></pre>
  
  <p>I was using my phone as emulator all along, and when I use the emulator from the studio itself it crashes, because of the length of array is null. And I thought I populated the array list already ? no ? </p>
  
  <p><strong>New error</strong></p>
  
  <pre><code>  01-30 13:48:55.551 4603-4603/? E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: com.example.kaiser.bdiary, PID: 4603
                                               java.lang.NullPointerException: Attempt to get length of null array
                                                   at com.example.kaiser.bdiary.Album.prepareData(Album.java:44)
                                                   at com.example.kaiser.bdiary.Album.onCreateView(Album.java:29)
                                                   at android.support.v4.app.Fragment.performCreateView(Fragment.java:2087)
                                                   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1113)
                                                   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
                                                   at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
                                                   at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1643)
                                                   at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
                                                   at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                   at android.support.v4.view.ViewPager.populate(ViewPager.java:1272)
                                                   at android.support.v4.view.ViewPager.populate(ViewPager.java:1120)
                                                   at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1646)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
                                                   at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                   at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                   at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                   at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                   at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
                                                   at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                   at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
                                                   at android.view.View.measure(View.java:18788)
                                                   at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
                                                   at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
                                                   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
                                                   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                   at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                   at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>