title: Updating of the data in the RecyclerView
body: <p>I have FirstscreenActivity, in which I use RecyclerView, (in this RecyclerView  displays pictures of the projects which were created by a user),  then user goes to the next Activity, where he creates new project and adds pictures there. When user comes back to the FirstScreenActivity, old project downloads one more time, and after that download new project.
  How to make that old projects wouldn't download one more time after the changing the Activities (so there wouldn't be duplicates)?</p>
  
  <pre><code>public class FirstscreenActivity extends AppCompatActivity implements RecyclerItemClickListener.OnItemClickListener {
  
      private MyAdapter mAdapter;
      private LinearLayoutManager mLayoutManager;
      public static String mCurrentProject = null;
  
      RecyclerView list;
  
      static File[] listFile;
      static File[] listFolders;
  
      static int newpressed = 0;
  
      public static ArrayList&lt;Folder&gt; FOLDERS = new ArrayList&lt;&gt;();
      public static LruCache&lt;String, Bitmap&gt; mMemoryCache;
  
      public static File[] listFile2;
  
  
      public void getFromSdcardFolders() {
          File file = new File(Environment.getExternalStorageDirectory() +
                  "/Audio_Recorder_Picture", "Previews");
          if (file.isDirectory()) {
              listFolders = file.listFiles();
              for (int i = 0; i &lt; listFolders.length; i++) {
  
                  Folder folderobject = new Folder();
                  folderobject.setName(listFolders[i].getName());
                  Log.i("List of FOLDERS: ", String.valueOf(listFolders[i].getName()));
  
                  File picturelist = new File(Environment.getExternalStorageDirectory() +
                          "/Audio_Recorder_Picture/Previews", listFolders[i].getName());
                  if (picturelist.isDirectory()) {
                      listFile = picturelist.listFiles();
                      for (int j = 0; j &lt; listFile.length; j++) {
                          folderobject.addFile(listFile[j].getAbsolutePath());
                      }
                  }
                  FOLDERS.add(folderobject);
                  Log.wtf("TAG", "Folders size inside the getFRom:" + FOLDERS.size());
              }
          }
      }
  
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.front);
          Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
          setSupportActionBar(myToolbar);
          getSupportActionBar().setTitle("");
  
          list = (RecyclerView) findViewById(R.id.list);
  
          list.setHasFixedSize(true);
  
          mLayoutManager = new LinearLayoutManager(getApplicationContext());
          mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          list.addOnItemTouchListener(new RecyclerItemClickListener(this, this));
  
          getFromSdcardFolders();
  
          list.setLayoutManager(mLayoutManager);
  
          mAdapter = new MyAdapter(this, FOLDERS);
          list.setAdapter(mAdapter);
          mAdapter.notifyDataSetChanged();
  
          final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
  
          // Use 1/8th of the available memory for this memory cache.
          final int cacheSize = maxMemory / 4;
  
          mMemoryCache
                  = new LruCache&lt;String, Bitmap&gt;(cacheSize) {
              @Override
              protected int sizeOf(String key, Bitmap bitmap) {
                  // The cache size will be measured in kilobytes rather than
                  // number of items.
                  return bitmap.getByteCount() / 1024;
              }
          };
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
  
          getMenuInflater().inflate(R.menu.menu, menu);
          return super.onPrepareOptionsMenu(menu);
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case R.id.addItem:
                  SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss");
                  Date now = new Date();
                  mCurrentProject = String.valueOf(formatter.format(now));
                  Log.d("newpressed: ", String.valueOf(newpressed));
                  Intent nextScreen = new Intent(getApplicationContext(), AudioRecord.class);
                  startActivity(nextScreen);
                  return true;
              default:
                  return super.onOptionsItemSelected(item);
          }
      }
  
      @Override
      public void onItemClick(View childView, int position) {
  
          File picturelist2 = new File(Environment.getExternalStorageDirectory() +
                  "/Audio_Recorder_Picture/Pictures", listFolders[position].getName());
          if (picturelist2.isDirectory()) {
              listFile2 = picturelist2.listFiles();
              for (int i = 0; i &lt; listFile2.length; i++) {
                  Log.i("LIST OF PICTURES: ", String.valueOf(listFile2[i]));
              }
  
          }
          Intent viewScreen = new Intent(getApplicationContext(), ViewActivity.class);
          viewScreen.putExtra("FILE_TAG", listFile2);
          startActivity(viewScreen);
      }
  
      @Override
      public void onItemLongPress(View childView, int position) {
  
      }
  }
  </code></pre>
  
  <p>Code of the adapter: </p>
  
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt;` {
  
      public final Activity context;
      public final ArrayList&lt;Folder&gt; FOLDERS;
      View view;
  
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public int getItemCount() {
          Log.wtf("TAG", "Folders size: " + FOLDERS.size());
          return FOLDERS.size();
      }
  
      // optimisation of bitmap
  
      public static int calculateInSampleSize(
              BitmapFactory.Options options, int reqWidth, int reqHeight) {
          // Raw height and width of image
          final int height = options.outHeight;
          final int width = options.outWidth;
          int inSampleSize = 1;
  
          if (height &gt; reqHeight || width &gt; reqWidth) {
  
              final int halfHeight = height / 2;
              final int halfWidth = width / 2;
  
              // Calculate the largest inSampleSize value that is a power of 2 and keeps both
              // height and width larger than the requested height and width.
              while ((halfHeight / inSampleSize) &gt; reqHeight
                      &amp;&amp; (halfWidth / inSampleSize) &gt; reqWidth) {
                  inSampleSize *= 2;
              }
          }
  
          return inSampleSize;
      }
  
      public static Bitmap decodeSampledBitmapFromResource(String path,
                                                           int reqWidth, int reqHeight) {
  
          // First decode with inJustDecodeBounds=true to check dimensions
          final BitmapFactory.Options options = new BitmapFactory.Options();
          options.inJustDecodeBounds = true;
          BitmapFactory.decodeFile(path, options);
  
          // Calculate inSampleSize
          options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
  
          // Decode bitmap with inSampleSize set
          options.inJustDecodeBounds = false;
          return BitmapFactory.decodeFile(path, options);
      }
  
      public void loadBitmap(String path, ImageView imageView, int position) {
          final String imageKey = String.valueOf(path);
  
          Bitmap bitmap = getBitmapFromMemCache(imageKey);
          if (bitmap != null) {
              imageView.setImageBitmap(bitmap);
          } else {
  
              bitmap = decodeSampledBitmapFromResource(path, 100, 100);
              imageView.setImageBitmap(bitmap);
             // BitmapWorkerTask task = new BitmapWorkerTask(imageView, position);
             // task.execute(path);
          }
      }
  
  
      public static class ViewHolder extends RecyclerView.ViewHolder {
          public TextView mTextView;
          public TextView title;
          public ImageView image1;
          ImageView image2;
          ImageView image3;
          ImageView image4;
          ImageView image5;
          TextView slides;
  
          public ViewHolder(View v) {
              super(v);
              title = (TextView) v.findViewById(R.id.item);
              image1 = (ImageView) v.findViewById(R.id.icon1);
              image2 = (ImageView) v.findViewById(R.id.icon2);
              image3 = (ImageView) v.findViewById(R.id.icon3);
              image4 = (ImageView) v.findViewById(R.id.icon4);
              image5 = (ImageView) v.findViewById(R.id.icon5);
              slides = (TextView) v.findViewById(R.id.textView1);
  
          }
      }
  
      public MyAdapter(Activity context, ArrayList&lt;Folder&gt; FOLDERS) {
          this.context = context;
          this.FOLDERS = FOLDERS;
          getItemCount();
      }
  
      @Override
      public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                     int viewType) {
  
          Log.wtf("TAG", "OnCreateViewHolder works!!!");
          view = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.mylist, parent, false);
          ViewHolder vh = new ViewHolder(view);
          return vh;
      }
  
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          Folder folder = FOLDERS.get(position);
  
          holder.image1.setImageResource(R.drawable.placeholder);
          holder.image2.setImageResource(R.drawable.placeholder);
          holder.image3.setImageResource(R.drawable.placeholder);
          holder.image4.setImageResource(R.drawable.placeholder);
          holder.image5.setImageResource(R.drawable.placeholder);
  
          ArrayList&lt;String&gt; imgs = folder.getPicturelist();
  
          holder.title.setText(folder.getName());
  
          BitmapFactory.Options options = new BitmapFactory.Options();
          options.inPreferredConfig = Bitmap.Config.RGB_565;
          options.inSampleSize = 10;
  
  
          for (int i = 0; i &lt; 5; i++) {
              switch (i) {
                  case 0:
                      if (imgs.size() &gt; i &amp;&amp; imgs.size() != 0) {
                          loadBitmap(imgs.get(i), holder.image1, position);
                      } else {
                          holder.image1.setImageBitmap(null);
                          // holder.image1.setImageResource(R.drawable.placeholder);
                      }
                      break;
                  case 1:
                      if (imgs.size() &gt; i &amp;&amp; imgs.size() != 0) {
                          loadBitmap(imgs.get(i), holder.image2, position);
                      } else {
                          holder.image2.setImageBitmap(null);
                          // holder.image2.setImageResource(R.drawable.placeholder);
                      }
                      break;
                  case 2:
                      if (imgs.size() &gt; i &amp;&amp; imgs.size() != 0) {
                          loadBitmap(imgs.get(i), holder.image3, position);
                      } else {
                          holder.image3.setImageBitmap(null);
                          // holder.image3.setImageResource(R.drawable.placeholder);
                      }
                      break;
                  case 3:
                      if (imgs.size() &gt; i &amp;&amp; imgs.size() != 0) {
                          loadBitmap(imgs.get(i), holder.image4, position);
                      } else {
                          holder.image4.setImageBitmap(null);
                          // holder.image4.setImageResource(R.drawable.placeholder);
                      }
                      break;
                  case 4:
                      if (imgs.size() &gt; i &amp;&amp; imgs.size() != 0) {
                          loadBitmap(imgs.get(i), holder.image5, position);
                      } else {
                          holder.image5.setImageBitmap(null);
                          // holder.image5.setImageResource(R.drawable.placeholder);
                      }
                      break;
              }
          }
  
          holder.slides.setText("Количество слайдов: " + imgs.size());
          view.setTag(holder);
      }
  
      public Bitmap getBitmapFromMemCache(String key) {
          return com.example.attracti.audiorecorderpicture.FirstscreenActivity.mMemoryCache.get(key);
  
      }
  }  
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myproject"&gt;
  
      &lt;uses-permission android:name="android.permission.CAMERA"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
      &lt;uses-feature android:name="android.hardware.camera" /&gt;
  
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/Theme.AppCompat.Light.NoActionBar"
          android:name=".model.App"
          &gt;
  
          &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  
          &lt;activity android:name=".activities.AudioRecord"
              android:screenOrientation="portrait"
              android:configChanges="orientation|keyboardHidden"&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".activities.FirstscreenActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".activities.ViewActivity"&gt;
      &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ZPakc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZPakc.png" alt="enter image description here"></a></p>