[Android] Use a neutral locale when formatting a string intented for SQLite

Ludovic Fauvet git at videolan.org
Tue Jul 3 19:39:56 CEST 2012


android | branch: master | Ludovic Fauvet <etix at videolan.org> | Tue Jul  3 19:32:50 2012 +0200| [f41a3a181ae606f81ee85e84e2f32bb262a56bcc] | committer: Ludovic Fauvet

Use a neutral locale when formatting a string intented for SQLite

By default String.format use the current locale to format strings which
is wrong for making SQL queries.
This was causing a crash for users running some locales, as the numbers
(%d for instance) were not using arabic numerals.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=f41a3a181ae606f81ee85e84e2f32bb262a56bcc
---

 vlc-android/src/org/videolan/vlc/DatabaseManager.java |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/DatabaseManager.java b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
index bc9d6ab..edd0848 100644
--- a/vlc-android/src/org/videolan/vlc/DatabaseManager.java
+++ b/vlc-android/src/org/videolan/vlc/DatabaseManager.java
@@ -28,6 +28,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 
 import android.content.ContentValues;
 import android.content.Context;
@@ -304,7 +305,8 @@ public class DatabaseManager {
 
         do {
             count = 0;
-            cursor = mDb.rawQuery(String.format("SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s LIMIT %d OFFSET %d",
+            cursor = mDb.rawQuery(String.format(Locale.ROOT,
+                    "SELECT %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s FROM %s LIMIT %d OFFSET %d",
                     MEDIA_TIME, //0 long
                     MEDIA_LENGTH, //1 long
                     MEDIA_TYPE, //2 int



More information about the Android mailing list