Reputation: 33
Where is the storage location of Application.Current.Properties of Xamarin Forms on Android?
Upvotes: 1
Views: 433
Reputation: 27126
The Xamarin Forms storage location of Application.Current.Properties
on Android is:
/data/data/YOUR_PACKAGE_NAME/files/.config/.isolated-storage/PropertyStore.forms
Test
In the Xamarin persist some property:
Application.Current.Properties["someKey"] = "someValue";
Afterwards:
adb root
adb shell
cd /data/data/YOUR_PACKAGE_NAME/files/.config/.isolated-storage/
ls
Demo:
Upvotes: 1
Reputation: 14475
You can directly check the source code on github and try to figure out where the storage location is .
Search the file Application
, and inside the class search keyword Properties
.
public IDictionary<string, object> Properties
{
get
{
if (_propertiesTask == null)
{
_propertiesTask = GetPropertiesAsync();
}
return _propertiesTask.Result;
}
}
async Task<IDictionary<string, object>> GetPropertiesAsync()
{
var deserializer = DependencyService.Get<IDeserializer>();
if (deserializer == null)
{
Log.Warning("Startup", "No IDeserialzier was found registered");
return new Dictionary<string, object>(4);
}
IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
if (properties == null)
properties = new Dictionary<string, object>(4);
return properties;
}
Search the file IDeserializer
and its implementation on Android platform.
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!store.FileExists(PropertyStoreFile))
return null;
using (IsolatedStorageFileStream stream = store.OpenFile(PropertyStoreFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
Search the file IsolatedStorageFile
and its implementation on Android platform.
public class _IsolatedStorageFile : IIsolatedStorageFile
{
readonly IsolatedStorageFile _isolatedStorageFile;
public _IsolatedStorageFile(IsolatedStorageFile isolatedStorageFile)
{
_isolatedStorageFile = isolatedStorageFile;
}
public Task CreateDirectoryAsync(string path)
{
_isolatedStorageFile.CreateDirectory(path);
return Task.FromResult(true);
}
At last , the implementation for CreateDirectory
is hidden , so that we can't get the exact file path , however I just show you how to get something from source code .
Upvotes: 1