Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:14:26+00:00 2026-06-14T10:14:26+00:00

I am getting DB values with following code: public List<String> getPlayerNames() { List<String> playerNames

  • 0

I am getting DB values with following code:

public List<String> getPlayerNames() {
        List<String> playerNames = new ArrayList<String>();
        c = myDataBase.rawQuery("SELECT * FROM PLAYERS",null);
        while (c.moveToNext()) {

            String q = c.getString(1);
            playerNames.add(q);

        }
        c.close();
        myDataBase.close();
        return playerNames;

    }

I now want to compare the items in this List to a String value with following method:

private boolean checkIfExists(String newPlayer) {
        // TODO Auto-generated method stub

        List<String> playerNames = myDbHelper.getPlayerNames();
        //here a loop?! 

        return false;
    }

But I don’t really know how to compare these list items with a string value. I tried with a for loop, but then again, a list doesn’t support a .length() method to go trough all elements? Tnx!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:14:28+00:00Added an answer on June 14, 2026 at 10:14 am
    for(String playerName : playerNames){
      if(playerName.equals(newPlayer)){
        return true;
      }
    }
    return false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method for getting values from database. public virtual List<TEntity> GetValues( int?
Given the following code why am I getting different values for a and b
I'm still searching solution for getting values from dynamic created object. Follwing code generates
I'm getting odd behavior (it generates only missing values) from the following loop -
Im getting the following error on the code I transleted from C# to VB.NET
When running the following code I end up getting negative values. I am only
The xmlns attribute in the following code stops me getting the value I need.
In the below program,i am not getting values from printf . #include<stdio.h> int main()
Im getting 2 values from a table and I'd like to compare them. If
I was wondering how could I improve the performance of the following code: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.