diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java
index a2356e6a3aee28b29fed5c8bff81e556c8ed339e..5edb46e277c220b3342852a6d24b28694c3ee59a 100644
--- a/java/src/com/android/inputmethod/research/ResearchLog.java
+++ b/java/src/com/android/inputmethod/research/ResearchLog.java
@@ -16,6 +16,7 @@
 
 package com.android.inputmethod.research;
 
+import android.content.Context;
 import android.util.JsonWriter;
 import android.util.Log;
 
@@ -23,7 +24,7 @@ import com.android.inputmethod.latin.define.ProductionFlag;
 
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -50,6 +51,8 @@ public class ResearchLog {
 
     /* package */ final ScheduledExecutorService mExecutor;
     /* package */ final File mFile;
+    private final Context mContext;
+
     private JsonWriter mJsonWriter = NULL_JSON_WRITER;
     // true if at least one byte of data has been written out to the log file.  This must be
     // remembered because JsonWriter requires that calls matching calls to beginObject and
@@ -78,12 +81,13 @@ public class ResearchLog {
         }
     }
 
-    public ResearchLog(final File outputFile) {
+    public ResearchLog(final File outputFile, Context context) {
         if (outputFile == null) {
             throw new IllegalArgumentException();
         }
         mExecutor = Executors.newSingleThreadScheduledExecutor();
         mFile = outputFile;
+        mContext = context;
     }
 
     public synchronized void close(final Runnable onClosed) {
@@ -206,7 +210,9 @@ public class ResearchLog {
     public JsonWriter getValidJsonWriterLocked() {
         try {
             if (mJsonWriter == NULL_JSON_WRITER) {
-                mJsonWriter = new JsonWriter(new BufferedWriter(new FileWriter(mFile)));
+                final FileOutputStream fos =
+                        mContext.openFileOutput(mFile.getName(), Context.MODE_PRIVATE);
+                mJsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(fos)));
                 mJsonWriter.beginArray();
                 mHasWrittenData = true;
             }
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index f464facf4384be1749298db423a0837dc88a13a4..f609a2710bde59c758f361d2c4e2f240ae298963 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -324,11 +324,22 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
         sIsLogging = enableLogging;
     }
 
+    private static int sLogFileCounter = 0;
+
     private File createLogFile(File filesDir) {
         final StringBuilder sb = new StringBuilder();
         sb.append(FILENAME_PREFIX).append('-');
         sb.append(mUUIDString).append('-');
-        sb.append(TIMESTAMP_DATEFORMAT.format(new Date()));
+        sb.append(TIMESTAMP_DATEFORMAT.format(new Date())).append('-');
+        // Sometimes logFiles are created within milliseconds of each other.  Append a counter to
+        // separate these.
+        if (sLogFileCounter < Integer.MAX_VALUE) {
+            sLogFileCounter++;
+        } else {
+            // Wrap the counter, in the unlikely event of overflow.
+            sLogFileCounter = 0;
+        }
+        sb.append(sLogFileCounter);
         sb.append(FILENAME_SUFFIX);
         return new File(filesDir, sb.toString());
     }
@@ -374,12 +385,12 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
             return;
         }
         if (mMainLogBuffer == null) {
-            mMainResearchLog = new ResearchLog(createLogFile(mFilesDir));
+            mMainResearchLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
             mMainLogBuffer = new MainLogBuffer(mMainResearchLog);
             mMainLogBuffer.setSuggest(mSuggest);
         }
         if (mFeedbackLogBuffer == null) {
-            mFeedbackLog = new ResearchLog(createLogFile(mFilesDir));
+            mFeedbackLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
             // LogBuffer is one more than FEEDBACK_WORD_BUFFER_SIZE, because it must also hold
             // the feedback LogUnit itself.
             mFeedbackLogBuffer = new FixedLogBuffer(FEEDBACK_WORD_BUFFER_SIZE + 1);
@@ -599,7 +610,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
                 uploadNow();
             }
         });
-        mFeedbackLog = new ResearchLog(createLogFile(mFilesDir));
+        mFeedbackLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
     }
 
     public void uploadNow() {