From 01e0913ad20b24cc2b7b4dc2f4cbac03ccd4bc0e Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 12 Oct 2012 18:07:30 +0900 Subject: Make a better choice for the temporary file Change-Id: I745bb285b6b52875c8d2b3a94deb962352f9754e --- .../com/android/inputmethod/latin/BinaryDictionaryGetter.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java') diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index c747dc673..ecb61b46f 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -165,14 +165,9 @@ final class BinaryDictionaryGetter { /** * Generates a unique temporary file name in the app cache directory. - * - * This is unique as long as it doesn't get called twice in the same millisecond by the same - * thread, which should be more than enough for our purposes. */ - public static String getTempFileName(String id, Context context) { - final String fileName = replaceFileNameDangerousCharacters(id); - return context.getCacheDir() + File.separator + fileName + "." - + Thread.currentThread().getId() + "." + System.currentTimeMillis(); + public static String getTempFileName(String id, Context context) throws IOException { + return File.createTempFile(replaceFileNameDangerousCharacters(id), null).getAbsolutePath(); } /** -- cgit v1.2.3-83-g751a