Getting data with RxJava and retrofit I am using RxJava with retrofit to get data from an API then filtering the data with a for loop in the onNext Method.  Is there any way not to use the for loop and just use RxJava to filter or improve the code?

 _subscriptions.add(
                jamSpeakServiceApi.getAllWords()
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new Observer&lt;List&lt;WordApi&gt;&gt;() {
                            @Override
                            public void onCompleted() {
                                Log.d("retroffit Completed", "Completed");
                            }

                            @Override
                            public void onError(Throwable e) {
                                Log.d("retroffit error", e.toString());
                            }

                            @Override
                            public void onNext(List&lt;WordApi&gt; wordApis) {
                                /*Observable.from(wordApis)
                                        .filter(s -&gt; Word.getWordFormDatabase(s.getWord()) != null)
                                        .filter(s -&gt; s.getCountry().toLowerCase().equals("jamaica"))
                                        .filter(s -&gt; Word.getWordLikeFormDatabase(s.getWord()) != null)
                                        .subscribe();*/

                                for (WordApi x: wordApis){
                                    if(x.getCountry().toLowerCase().equals("jamaica")== true){
                                        Word.saveWordFromApi(x);
                                        Log.d(x.getWord(),x.getWord());
                                    }
                                }

                            }
                        })
        );
You should use flat to emit each wordApi and then you will be able to filter your data and apply your function one by one. 

Your stream should look like this:

jamSpeakServiceApi.getAllWords()
            .subscribeOn(Schedulers.io())
            .flatMap(wordApis -&gt; Observable.from(wordApis))
            .filter(wordApi -&gt; wordApi.getCountry().toLowerCase().equals("jamaica"))
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer&lt;WordApi&gt;() {
                @Override
                public void onCompleted() {
                    Log.d("retroffit Completed", "Completed");
                }

                @Override
                public void onError(Throwable e) {
                    Log.d("retroffit error", e.toString());
                }

                @Override
                public void onNext(WordApi wordApi) {
                    Word.saveWordFromApi(wordApi);
                    Log.d(wordApi.getWord(),wordApi.getWord());
                }
            })


I used some lambdas, and I recommend you to use them too. Take a look at the Retrolambda Gradle plugin. It works well with an Android environment.