﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using FieldApp.Services;
using System.IO;
using FieldApp.Droid.Services;

[assembly: Xamarin.Forms.Dependency(typeof(FileStorage))]
namespace FieldApp.Droid.Services
{
    public class FileStorage : IFileStorage
    {
        public string GetToken(string fileName)
        {
            var documentPath =
                System.Environment
                .GetFolderPath(System.Environment
                                .SpecialFolder.Personal);

            var filePath = Path.Combine(documentPath, fileName);

            return System.IO.File.ReadAllText(filePath);
        }

        public void SaveToken(string fileName, string text)
        {
            var documentPath = 
                System.Environment
                .GetFolderPath(System.Environment
                                .SpecialFolder.Personal);

            var filePath = Path.Combine(documentPath, fileName);

            System.IO.File.WriteAllText(filePath, text);
        }
    }
}