You're not forced to use SQLiteOpenHelper. It gives nice benefits as far as
creating/updating the database for you, but it's definitely not required. My
suggestion would be to have your data layer return a collection of your
objects that the application can consume. Then your data layer can be more
reusable across platforms as you mentioned, since the layer doesn't really
care how the collection is being used.

You also mentioned not knowing how to call into a base class constructor
from the deriving class. In my sample code you posted, you can see I'm doing
that in my helper class:

public NoteDatabaseHelper(Context context)
   : base(context, DATABASE_NAME, null, DATABASE_VERSION)

The call to "base" there is referencing the constructor in the base class.

On Tue, Oct 18, 2011 at 7:52 AM, bmellac <bmel...@nomadvantage.com> wrote:

> Thx for the answers !
>
> SO I have two (maybe 3) solutions :
>
>  - use the Android sqlite classes : so it won't be crosscompilabe, but
> maybe
> it's just a little drawback if I manage to isolate the platform UI specific
> code...
> But for that , I need to actually manage to use Android's sqlite
> framework... but I'm stick on SQLiteOpenHelper : I have to subclass it but
> I
> can't see how to call the base (super in java?) call constructor like here
> :
> public class NoteDatabaseHelper : SQLiteOpenHelper
> {
>  private const string DATABASE_NAME = "Notes";
>  private const int DATABASE_VERSION = 1;
>
>  public NoteDatabaseHelper(Context context)
>    : base(context, DATABASE_NAME, null, DATABASE_VERSION)
>  {
>  }
>
>  public override void OnCreate(SQLiteDatabase db)
>  {
>    db.ExecSQL(@"
>        CREATE TABLE Note (
>          Id INTEGER PRIMARY KEY AUTOINCREMENT,
>          Title TEXT NOT NULL,
>          Contents TEXT NOT NULL
>        )");
>  }
>
>  public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int
> newVersion)
>  {
>    db.ExecSQL("DROP TABLE IF EXISTS Note");
>
>    OnCreate(db);
>  }
> }
>
> - the second method would like to be using ArrayAdapter, but then I have to
> extracting data from the sqlite database to pack them into arrays, don't
> seem really pretty !
>
> - maybe the third option would be to create a class, implementing ICursor,
> and taking an SqliteDataReader... but it seems harder and I'd like to know
> I'm heading strait to the wall :)
>
> Am I missleading ?
>
> --
> View this message in context:
> http://mono-for-android.1047100.n5.nabble.com/Mono-Data-Sqlite-and-cursors-tp4913036p4913390.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to