diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java
index 67da4fa5020f3c9b99e777d9a2203146d6dba486..0bbbf3995e162e5b0e4866d6e21bc39a3a983771 100644
--- a/java/src/com/android/inputmethod/latin/UserDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserDictionary.java
@@ -179,8 +179,9 @@ public class UserDictionary extends ExpandableDictionary {
         new Thread("addWord") {
             @Override
             public void run() {
+                Cursor cursor = null;
                 try {
-                    final Cursor cursor = client.query(Words.CONTENT_URI, PROJECTION_ADD,
+                    cursor = client.query(Words.CONTENT_URI, PROJECTION_ADD,
                             "word=? and ((locale IS NULL) or (locale=?))",
                                     new String[] { word, mLocale }, null);
                     if (cursor != null && cursor.moveToFirst()) {
@@ -201,6 +202,9 @@ public class UserDictionary extends ExpandableDictionary {
                     // If we come here, the activity is already about to be killed, and we
                     // have no means of contacting the content provider any more.
                     // See ContentResolver#insert, inside the catch(){}
+                } finally {
+                    if (null != cursor) cursor.close();
+                    client.release();
                 }
             }
         }.start();