Xamarin can not find refunds - Sqlite

0

Hello friends I am trying to store some data locally on my device with SQLite , but I have encountered some problems. I was researching that in order to store data on a device from Xamarin we must make different routes for each type of device, and that the way in which we route that route is through an interface. But I have not been around for some time without Xamarin finding my reference class ... another thing is that I'm not getting an error.

using System;
using System.Collections.Generic;
using System.Text;
using SQLite.Net.Interop;
namespace OwsX
{
    public interface IConfig
    {
        string DbPath { get; }
        ISQLitePlatform Platform { get; }
    }
}

This is my configuration class for Android and as you can see it does not find my other class IConfig

using Android.Widget;
using SQLite.Net.Interop;

namespace OwsX.Droid {
  class Config: IConfig {
    private string dbPath;
    private ISQLitePlatform platform;
    public string DbPath {
      get {
        if (string.IsNullOrEmpty(dbPath)) {
          var directory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
        }
        return dbPath;
      }
    }

    public ISQLitePlatform Platform {
      get {
        if (platform == null) {
          platform = new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid();
        }
        return platform;
      }
    }
  }
}

If anyone knows what is going on, I would be infinitely grateful for your comment. Thanks:)

    
asked by E.Rawrdríguez.Ophanim 14.02.2018 в 01:11
source

2 answers

1

Well at the end of the options that I suggested VS I chose in which said - Generate new type - and the following interface appeared, and here I only pointed to the project Shared and ready reference list: D

    
answered by 14.02.2018 / 16:33
source
1

Are you sure that your android project refers to the PCL project? I give you an example as I have it:

Interface in the PCL:     using SQLite;

namespace Aplicacion.PCL.Interfaces
{
    public interface ISQLite
    {
        SQLiteAsyncConnection GetConnection();

    }
}

Implementation on android:

using Aplicacion.PCL.Interfaces;
using System.IO;
using SQLite;
using Aplicacion.Droid.Interfaces;

[assembly: Xamarin.Forms.Dependency(typeof(SQLiteClient))]
namespace Aplicacion.Droid.Interfaces
{
    public class SQLiteClient : ISQLite
    {
        public SQLiteAsyncConnection GetConnection()
        {
            var sqliteFilename = "db_name.db3";
            string rutaFisica = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), sqliteFilename);
            return new SQLiteAsyncConnection(rutaFisica);
        }            
    }
}
    
answered by 14.02.2018 в 11:16