Port the SQLite locale setting code to Java.

Make the database opening code more robust in the case of
read-only database connections.

Check whether a PRAGMA needs to be issues before doing it.
Mostly it's harmless but it can grab a transaction on the
database unnecessarily.

Change-Id: Iab2cdc96c785e767f82966b00597e19337163f2f
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index d41b484..bf32ea7 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -1718,7 +1718,7 @@
 
     /**
      * Sets the locale for this database.  Does nothing if this database has
-     * the NO_LOCALIZED_COLLATORS flag set or was opened read only.
+     * the {@link #NO_LOCALIZED_COLLATORS} flag set or was opened read only.
      *
      * @param locale The new locale.
      *