# Filter list to database

**URL:** <https://discuss.kotlinlang.org/t/filter-list-to-database/26712>\
**Category:** Android\
**Created:** [April 20, 2023, 6:42am UTC](https://discuss.kotlinlang.org/t/filter-list-to-database/26712 "2023-04-20T06:42:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jmonsa97](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@Jmonsa97](https://discuss.kotlinlang.org/u/Jmonsa97)\
**Post date:** [April 20, 2023, 6:42am UTC](https://discuss.kotlinlang.org/t/filter-list-to-database/26712/1 "2023-04-20T06:42:23Z")

</div>

Hello, I have a recycleview and an adapter to fill it but I have problems filtering a search within the list, my list is not local, my list is received from a function that is responsible for loading it to display it in a fragment, I have implemented several types of search methods but it simply does not show me anything from the list, my list is only replaced by an empty one without showing me anything… i need help

---

<div class="post-metadata">

**Author:** ![raphael.tarita](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@raphael.tarita](https://discuss.kotlinlang.org/u/raphael.tarita)\
**Post date:** [April 21, 2023, 7:37am UTC](https://discuss.kotlinlang.org/t/filter-list-to-database/26712/2 "2023-04-21T07:37:33Z")

</div>

It’s hard to tell what the problem really is or how to solve it without code. From what I can tell, you have a function that returns a list:

```kotlin
fun provideList(): List<String>

```

(element type may be different)  
And you want to filter that list?

In that case, you’d just do:

```kotlin
provideList().filter { /*your condition*/ }

```

For example:

```kotlin
provideList().filter { it.startsWith(userInput) }

```

Note that `filter` returns a new, immutable List and leaves the original list it was called on untouched.

---

<div class="post-metadata">

**Author:** ![Jmonsa97](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@Jmonsa97](https://discuss.kotlinlang.org/u/Jmonsa97)\
**Post date:** [April 22, 2023, 4:04am UTC](https://discuss.kotlinlang.org/t/filter-list-to-database/26712/3 "2023-04-22T04:04:24Z")

</div>

Hello, it turns out that I managed to adapt my filter to my recycler, but I have a question… although I don’t like to bother much, I have a layout that works as a nav\_header, for a drawer menu, but I have 2 information parameters that I want to send to that nav header according to the user, but I can’t find how, I want to know if I can use the layout of an activity or fragment as a drawer menu nav header? Or if I can use an adapter class to send the information to that layout? In case that is not possible, how can I call my layout nav\_header, from the activity where my drawer menu is configured, to change the items already created in it, for ones that come from a database where the user is saved? I summarize everything… how can I make the user’s profile photo and name appear in the nav header of my menu? Would any of the previous methods work or am I very wrong?

---

<div class="post-metadata">

**Author:** ![raphael.tarita](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@raphael.tarita](https://discuss.kotlinlang.org/u/raphael.tarita)\
**Post date:** [May 8, 2023, 12:02pm UTC](https://discuss.kotlinlang.org/t/filter-list-to-database/26712/4 "2023-05-08T12:02:22Z")

</div>

I have no idea, but it sounds like a question more suited for dedicated android development forums
