MrGibbage
MrGibbage

Reputation: 2646

Using java String.format on a android sqlite arguments

Android sqlite commands are like db.delete(table, whereClause, whereArgs); whereClause is a string such as "column1 = ? and column2 = ?" whereArgs is a string array that holds the values that will be substituted in the whereClause. Is there an easy way for me to get the decoded string from this (for logging purposes). String.format seems close, but not quite. This is what I am aiming for:

 Log.e(MY_DEBUG_TAG, 
     "Error executing Delete(" + table + ", " + 
            String.format(whereClause, whereArgs + ")");

Upvotes: 0

Views: 807

Answers (1)

Diego Torres Milano
Diego Torres Milano

Reputation: 69198

If only for logging purposes you may try:

 Log.e(MY_DEBUG_TAG, 
     "Error executing Delete(" + table + ", " + 
            String.format(whereClause.replaceAll("\\?", "%s"), (Object[])whereArgs) + ")");

Upvotes: 2

Related Questions