0

This is further to my question earlier, on the db.update.

I'm used the code Karakuri's suggested and modified the database adapter method to the following. Note that fma in an integer number (34, actually) the database adapter got from mainactivity

    public void updateJ(int fma){
         String where = "coli = ?";

        ContentValues arw = new ContentValues();
        cv.put("coli", fma);

            the below no longer used but null the last argument instead
        //  String jusi =  Integer.toString(fma);
        // String[] whereArgs = new String[] {jusi};
        //Log.w(TAG, "whereArgs = " + whereArgs);


        db.update("superTable", cv, where, null);
            }

It still does not work. // from previous 'the log.w reads as 06-02 16:24:31.695: W/DBA information(18940): whereArgs = [Ljava.lang.String;@5299a034'

//But I have a question after reading online tutorials and android website and also Karakuri's explanation that the fourth argument whereArgs is suppose to be a String[] instead of a String or an int. But the column 'coli' in superTable is an integer by design. How do I go about making it accept an int rather than a String[]?

I've replaced the whereargs with null and essentially use the cv.put directly using the int fma variable, but it still doesn't work? converted the int to string before putting in and it doesnt work also.

7
  • why are you making it an array in the first place? plus is your "coli" column an int or a string? why are you comparing an int with a string array? Commented Jun 2, 2014 at 16:33
  • coli is an int. The db.update() method will not accept a int or a string as whereArgs. The method update(String, ContentValues, String, String[]) in the type SQLiteDatabase is not applicable for the arguments (String, ContentValues, String, int) Commented Jun 2, 2014 at 16:39
  • just to give you the ideas. stackoverflow.com/questions/9798473/… and here stackoverflow.com/questions/5987863/… --- see the last param is null there :))) Commented Jun 2, 2014 at 16:42
  • Thanks for the suggestion. I've just tried putting 'null' instead of 'whereArgs' but its still not updating.. Commented Jun 2, 2014 at 16:49
  • Should I convert the fma to a String? .. hmm . scratch that. Just converted it to string and reinsert and it still doesnt work Commented Jun 2, 2014 at 16:53

1 Answer 1

0

It still does not work. // from previous 'the log.w reads as 06-02 16:24:31.695: W/DBA information(18940): whereArgs = [Ljava.lang.String;@5299a034'

You don't pass the whereArgs to the update(), that's why it "does not work". Change

db.update("superTable", cv, where, null);

to

db.update("superTable", cv, where, whereArgs);

The log output is what one would expect when calling toString() on a String[] string array.

Sign up to request clarification or add additional context in comments.

Comments

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.