I have a free Android app that has spread beyond the original intended user base. I encountered an instance where this kind of String.format produced an invalid SQL string:
String sql = String.format ("SELECT name from customers where cust_id=%d", cust_id);
One situation that definitely caused a problem is where the user's localisation was for arabic, so the customer id was represented in arabic characters.
I fixed that particular problem like this:
String sql = String.format (Locale.ENGLISH, "SELECT name from customers where cust_id=%d", cust_id);
What delayed finding a solution was that, because it's a free app, most people don't report a problem- they just stop using the app: I only get to find out from crash logs. Furthermore, the nature of the localisation seemed to depend both on the selected language and also the version of Android... and the app is supported all the way back to V2.1. I have detected two different types just for arabic, and another (I haven't identified the language) that localised the digits to question marks.
My question is whether there will be a similar problem with statements that generate sql queries using concatenation, like this:
String sql = "SELECT name from customers where cust_id=" + cust_id;
The majority of my queries are like this, so it would be a big job to check and change. I can test it empirically on current versions, but how about previous and future ones?