title: I can auto increment id in room database but when refresh database it's shows double
body: <p>In my app firstly i am fetching data from server using retrofit then it's saved in room database table then it shows in recyclerview but when i using a id as a primary key it's show only one data then this id i annotat autoGenerate = true then it's show all data which i put in server but when i reopen my app,it's show double data(this mean firstly i have 3 data in server,this app show 3 data but when i reopen or refresh my database it's show 6 data ,every time in refresh it's increasing).but i want this id will be increase but data will be not increase that's mean server have 3 data and it's store in room database table.</p>
  <p>Movie.kt</p>
  <pre><code>@Entity(tableName = &quot;movie_table&quot;)
  data class Movie(
  @PrimaryKey(autoGenerate = true)
  var id: Int = 0,
  @SerializedName(&quot;Title&quot;)
  @Expose
  val title: String,
  @SerializedName(&quot;Year&quot;)
  @Expose
  val Year: Int,
  @SerializedName(&quot;Genre&quot;)
  @Expose
  val genre: String,
  @SerializedName(&quot;Language&quot;)
  @Expose
  val language: String,
  @SerializedName(&quot;Country&quot;)
  @Expose
  val country: String,
  @SerializedName(&quot;Poster&quot;)
  @Expose
  val poster: String,
  @SerializedName(&quot;Plot&quot;)
  @Expose
  val plot:String
  )
  </code></pre>
  <p>MovieDao.kt</p>
  <pre><code>@Dao
  interface MovieDao {
  @Insert(onConflict = OnConflictStrategy.REPLACE)
  suspend fun insertMovie(movie: Movie)
  
  @Query(&quot;SELECT * FROM movie_table&quot;)
  suspend fun getAllMovieDB(): List&lt;Movie&gt;
  
  @Query(&quot;SELECT * FROM movie_table WHERE title LIKE :title&quot;)
  suspend fun getSearchMovieDB(title: String): List&lt;Movie&gt;
  }
  </code></pre>
  <p>MovieDatabase.kt</p>
  <pre><code>@Database(
  entities = [Movie::class],
  version = 1)
  abstract class MovieDatabase: RoomDatabase() {
  abstract fun getMovieDao(): MovieDao
  
  companion object{
      @Volatile
      private var instance : MovieDatabase? = null
      private val LOCK = Any()
      operator fun invoke(context: Context) = instance
          ?: synchronized(LOCK){
              instance
                  ?: buildDatabase(context).also{
                      instance = it
                  }
          }
      private fun buildDatabase(context: Context) = Room.databaseBuilder(
          context.applicationContext,
          MovieDatabase::class.java,
          &quot;movieDatabase&quot;
      ).build()
  }
  }
  </code></pre>
  <p>Repository.kt</p>
  <pre><code>class Repository(context: Context) {
  private val movieDao: MovieDao = MovieDatabase.invoke(context).getMovieDao()
  private val movieCall = MovieApiClient.movieApi
  suspend fun insertMovie(movie: Movie) {
      movieDao.insertMovie(movie)
  }
  suspend fun searchData(title: String): List&lt;Movie&gt; {
      return movieDao.getSearchMovieDB(title)
  }
  suspend fun getAllMovieDB(): List&lt;Movie&gt; {
      return movieDao.getAllMovieDB().also {
          getAllMovieFromServer()
      }
  }
  private suspend fun getAllMovieFromServer() {
      try {
          val movieList = movieCall.getAllMovie()
          movieList.forEach {
              insertMovie(it)
          }
      } catch (exception: Throwable) {
      }
  }
  }
  </code></pre>
  <p>better understanding with image
  (1)when id as a primary key without &quot;autoGenerate = true&quot; annotate
  <a href="https://i.stack.imgur.com/FYluS.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>(2)when id as a primary key with &quot;autoGenerate = true&quot; annotate
  <a href="https://i.stack.imgur.com/QZdP1.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>How can I increase id without double data, How can i fix this? Please help me, Thank you.</p>