title: SQLite: Escaping Special Characters
body: <p>Is there a common way within Android to escape all of the characters that aren't allowed in a SQLite database?  For instance, "You\'Me'".  Instead of me figuring out every single character that has isn't allowed and creating a bunch or replace statements.  I'm looking for something like the following.</p>
  
  <pre><code>value = SQLite.escapeString(value);
  ContentValues contentValues = new ContentValues();
  contentValues.put("name", value);
  getContentResolver().insert(CONTENT_URI, contentValues);
  
  //Retrieve data
  Cursor cursor = getContentResolver().query(CONTENT_URI, null, "name=?", new String[]{SQLite.escapeString(value)}, null);
  value = SQLite.unescapeString(cursor.getString(cursor.getColumnIndex("name"));
  </code></pre>
  
  <p>Is this wishful thinking or is there something out there already that solves this?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The code above works but in the situations where you can't use the ? operator you still need some way for escaping all of the characters.  For instance:</p>
  
  <pre><code>db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" 
  + KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
  + KEY_CATEGORY + " TEXT DEFAULT Misc.);");
  </code></pre>
  
  <p>The <code>.</code> in this example will throw an exception along with several other characters.  Is there a common method/way to escape all of these characters?</p>