Kevik
Kevik

Reputation: 9351

Using int value in selection args argument of sqlite for android

Is this the correct way to convert an int into a string before use with Integer.toString()? Is there another way to do this where conversion is not required?

Example:

 int value = 10;
 Cursor cursor = database.query(
    "TABLE_X", 
    new String[] { "COLUMN_A", "COLUMN_B" },
    "COLUMN_C = ?",
    new String[] { Integer.toString(value) },
    null,
    null,
    null);

Upvotes: 2

Views: 5329

Answers (1)

Avadhani Y
Avadhani Y

Reputation: 7626

Yes, you can use the following ways to convert int to String.

int i=10;
String[] str = new String[]{String.valueOf(i)};
String[] str1 = new String[]{Integer.toString(i)};

Upvotes: 7

Related Questions