protected override IDiskCache CreatePlatformDiskCacheInstance(Configuration configuration) { if (string.IsNullOrWhiteSpace(configuration.DiskCachePath)) { var context = new Android.Content.ContextWrapper(Android.App.Application.Context); string tmpPath = context.CacheDir.AbsolutePath; string cachePath = Path.Combine(tmpPath, "FFSimpleDiskCache"); Java.IO.File androidTempFolder = new Java.IO.File(cachePath); if (!androidTempFolder.Exists()) { androidTempFolder.Mkdir(); } if (!androidTempFolder.CanRead()) { androidTempFolder.SetReadable(true, false); } if (!androidTempFolder.CanWrite()) { androidTempFolder.SetWritable(true, false); } configuration.DiskCachePath = cachePath; } return(new SimpleDiskCache(configuration.DiskCachePath, configuration)); }
/// <summary> /// Creates new cache default instance. /// </summary> /// <returns>The cache.</returns> /// <param name="cacheName">Cache name.</param> public static SimpleDiskCache CreateCache(string cacheName, Configuration configuration) { #if __ANDROID__ var context = new Android.Content.ContextWrapper(Android.App.Application.Context); string tmpPath = context.CacheDir.AbsolutePath; string cachePath = Path.Combine(tmpPath, cacheName); Java.IO.File androidTempFolder = new Java.IO.File(cachePath); if (!androidTempFolder.Exists()) { androidTempFolder.Mkdir(); } if (!androidTempFolder.CanRead()) { androidTempFolder.SetReadable(true, false); } if (!androidTempFolder.CanWrite()) { androidTempFolder.SetWritable(true, false); } #else var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string tmpPath = Path.Combine(documents, "..", "Library", "Caches"); string cachePath = Path.Combine(tmpPath, cacheName); #endif return(new SimpleDiskCache(cachePath, configuration)); }
/// <summary> /// Creates new cache default instance. /// </summary> /// <returns>The cache.</returns> /// <param name="cacheName">Cache name.</param> public static SimpleDiskCache CreateCache(string cacheName, Configuration configuration) { #if __ANDROID__ var context = new Android.Content.ContextWrapper(Android.App.Application.Context); string tmpPath = context.CacheDir.AbsolutePath; string cachePath = Path.Combine(tmpPath, cacheName); #else var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string tmpPath = Path.Combine(documents, "..", "Library", "Caches"); string cachePath = Path.Combine(tmpPath, cacheName); #endif return new SimpleDiskCache(cachePath, configuration); }
/// <summary> /// Creates new cache default instance. /// </summary> /// <returns>The cache.</returns> /// <param name="cacheName">Cache name.</param> public static SimpleDiskCache CreateCache(string cacheName, Configuration configuration) { #if __ANDROID__ var context = new Android.Content.ContextWrapper(Android.App.Application.Context); string tmpPath = context.CacheDir.AbsolutePath; string cachePath = Path.Combine(tmpPath, cacheName); #else var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string tmpPath = Path.Combine(documents, "..", "Library", "Caches"); string cachePath = Path.Combine(tmpPath, cacheName); #endif return(new SimpleDiskCache(cachePath, configuration)); }