Answer the question
In order to leave comments, you need to log in
How to save serialized objects on the user's device in JSON format in an android application on Xamarin?
I'm trying to do it with simple methods, but it says "Access to the path /data.json is denied".
How can I bypass protection?
Made it a regular entry
File.WriteAllText("data.json", serializeString);
Answer the question
In order to leave comments, you need to log in
1 add permission to manifest
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
public static string DbPath => DependencyService.Get<ISqLite>().GetDatabasePath("user.db");
#region License
// Разработано: Коротенко Владимиром Николаевичем (Vladimir N. Korotenko)
// email: [email protected]
// skype:vladimir-korotenko
// https://vkorotenko.ru
// Создано: 09.04.2019 22:38
#endregion
using System;
using System.IO;
using SpecialForcesDirectory.Code;
using SpecialForcesDirectory.Droid;
using Xamarin.Forms;
[assembly: Dependency(typeof(SQLite_Android))]
namespace SpecialForcesDirectory.Droid
{
public class SQLite_Android : ISqLite
{
public SQLite_Android() { }
public string GetDatabasePath(string sqliteFilename)
{
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var path = Path.Combine(documentsPath, sqliteFilename);
return path;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question