1

I am trying to add an integer to my database but it wont let me.

    int count =0;
    public void editHighScores(){

    HashMap<String, String> queryValues = new HashMap<String, String>();
    queryValues.put("totalWins", count);

    myDatabase.insertHighScores(queryValues);
}

2 Answers 2

2

You have define the Map to accept String keys and String values, so you can'y put an int as value.

If you are not sure the value type, then Keep it as Object like

HashMap<String, Object> queryValues = new HashMap<String, Object>();

Or, if you know values will be always int only, then define like

HashMap<String, Integer> queryValues = new HashMap<String, Integer>();
Sign up to request clarification or add additional context in comments.

Comments

0

Okay, HashMap is expecting two strings. Try doing HashMap<String, Integer> = new HashMap<String, Integer>();

2 Comments

int as generic type? not possible
It would have to be HashMap<String, Integer>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.