# How to migrate to getMessagesByTimestamp from getPreviousMessagesByTimestamp on android

**URL:** <https://community.sendbird.com/t/how-to-migrate-to-getmessagesbytimestamp-from-getpreviousmessagesbytimestamp-on-android/6356>\
**Category:** Android\
**Created:** [January 16, 2023, 5:01am UTC](https://community.sendbird.com/t/how-to-migrate-to-getmessagesbytimestamp-from-getpreviousmessagesbytimestamp-on-android/6356 "2023-01-16T05:01:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arjun](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/arjun/32/1066_2.png) [@arjun](https://community.sendbird.com/u/arjun)\
**Post date:** [January 16, 2023, 5:01am UTC](https://community.sendbird.com/t/how-to-migrate-to-getmessagesbytimestamp-from-getpreviousmessagesbytimestamp-on-android/6356/1 "2023-01-16T05:01:28Z")

</div>

**[Problem/Question]**  
How to migrate from getMessagesByTimestamp to getPreviousMessagesByTimestamp on android

currently i have this implementation to fetch messages

```auto
channel?.getPreviousMessagesByTimestamp(
                    createdAt ?: Long.MAX_VALUE,
                    false,
                    CHANNEL_MESSAGE_LIMIT,
                    true,
                    BaseChannel.MessageTypeFilter.ALL,
                    null,
                    null,
                    true,
                    messageHandler
            )

```

i tried migrating to the newer api, it was a bit confusing but i ended up with this,

```auto

val params = MessageListParams(
                CHANNEL_MESSAGE_LIMIT,
                CHANNEL_MESSAGE_LIMIT,
                BaseChannel.MessageTypeFilter.ALL,
                allowedMessageTypes,
                userIds,
                false,
                true,
                true,
                true,
                true,
                true,
                true
            )

            channel?.getMessagesByTimestamp(
                createdAt ?: Long.MAX_VALUE,
                params,
                messageHandler
            )

```

but this implementation didn’t work, the pagination just returns the same set of messages and completely broke the current implementation.

* * *

SDK Version: v3.1.24

---

<div class="post-metadata">

**Author:** ![arjun](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/arjun/32/1066_2.png) [@arjun](https://community.sendbird.com/u/arjun)\
**Post date:** [January 30, 2023, 12:01pm UTC](https://community.sendbird.com/t/how-to-migrate-to-getmessagesbytimestamp-from-getpreviousmessagesbytimestamp-on-android/6356/2 "2023-01-30T12:01:42Z")

</div>

@Cjeon any inputs or any headsup?

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/tyler/32/810_2.png) [@Tyler](https://community.sendbird.com/u/Tyler)\
**Post date:** [January 31, 2023, 8:58am UTC](https://community.sendbird.com/t/how-to-migrate-to-getmessagesbytimestamp-from-getpreviousmessagesbytimestamp-on-android/6356/3 "2023-01-31T08:58:08Z")

</div>

Hello @arjun,

Apologize for the delay in our response. I had a change to speak with one of our Android engineers and it sounds like you should be passing `0` to `nextResultSize` instead of `CHANNEL_MESSAGE_LIMIT`. This is likely what is causing you to receive the duplicate data.
