diff options
author | Michael Jurka <mikejurka@google.com> | 2014-01-06 14:33:50 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2014-01-09 14:34:19 +0100 |
commit | 8b51b173209a9627157172f22fa23fa36065b061 (patch) | |
tree | a1a756817aacc955ebc560f350be010ed4acc594 /WallpaperPicker/src/com/android/launcher3 | |
parent | 872e70e0b648af572f660c2b432786ac63545e4c (diff) | |
download | android_packages_apps_Trebuchet-8b51b173209a9627157172f22fa23fa36065b061.tar.gz android_packages_apps_Trebuchet-8b51b173209a9627157172f22fa23fa36065b061.tar.bz2 android_packages_apps_Trebuchet-8b51b173209a9627157172f22fa23fa36065b061.zip |
Move saved wallpaper images from cache directory to data directory
Bug: 12028275
Change-Id: Ia8fdd0ea50a4dad34e560287c50ae3fcc6d09cf9
Diffstat (limited to 'WallpaperPicker/src/com/android/launcher3')
-rw-r--r-- | WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java index 58add7022..44bfdf1f9 100644 --- a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java +++ b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java @@ -85,6 +85,9 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { } public SavedWallpaperImages(Activity context) { + // We used to store the saved images in the cache directory, but that meant they'd get + // deleted sometimes-- move them to the data directory + ImageDb.moveFromCacheDirectoryIfNecessary(context); mDb = new ImageDb(context); mContext = context; mLayoutInflater = context.getLayoutInflater(); @@ -215,11 +218,20 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { Context mContext; public ImageDb(Context context) { - super(context, new File(context.getCacheDir(), DB_NAME).getPath(), null, DB_VERSION); + super(context, context.getDatabasePath(DB_NAME).getPath(), null, DB_VERSION); // Store the context for later use mContext = context; } + public static void moveFromCacheDirectoryIfNecessary(Context context) { + // We used to store the saved images in the cache directory, but that meant they'd get + // deleted sometimes-- move them to the data directory + File oldSavedImagesFile = new File(context.getCacheDir(), ImageDb.DB_NAME); + File savedImagesFile = context.getDatabasePath(ImageDb.DB_NAME); + if (oldSavedImagesFile.exists()) { + oldSavedImagesFile.renameTo(savedImagesFile); + } + } @Override public void onCreate(SQLiteDatabase database) { database.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" + |