Why would you want to bundle it with your app? What are the pros and cons?

Could you maybe illustrate me a method that executes a simple select query and 
returns the amount of rows? For say like a login method.. I tryed to find 
methods for that in sqlite but didnt succeed..

I really appreciate your help, thanks alot Jon.

- mittchel

Op 14 sep. 2011 om 22:56 heeft Jonathan Pryor <j...@xamarin.com> het volgende 
geschreven:

> On Sep 14, 2011, at 4:45 PM, Mittchel wrote:
>> I habr to admit that I am new with Mono. I tryed to establish a connection 
>> with Sqlite in monodroid. I am still having trouble with the database. If i 
>> put the file in the root of the project would my conn string be this: Data 
>> Source=myfile.db?
> 
> You'll notice that the original sample I showed you did something 
> interesting: if the file didn't exist, it created it programmatically:
> 
>            bool exists = File.Exists (db);
>            if (!exists)
>                SqliteConnection.CreateFile (db);
>            var conn = new SqliteConnection("Data Source=" + db);
>            if (!exists) {
>                var commands = new[] {
>                    "CREATE TABLE Items (Key ntext, Value ntext)",
>                    "INSERT INTO [Items] ([Key], [Value]) VALUES ('sample', 
> 'text')",
>                };
>                foreach (var cmd in commands)
>                    WithCommand (c => {
>                        c.CommandText = cmd;
>                        c.ExecuteNonQuery ();
>                    });
>            }
>            return conn;
> 
> If you don't want to programmatically create the database, and you instead 
> want to bundle it with your app, what you'll need to do is place the database 
> into your Assets folder, then use the Assets APIs to copy the database onto 
> disk before you attempt to access it. Alternatively, you could embed the 
> database as an assembly resource, then  use the Reflection APIs to find and 
> extract the resource.
> 
> There is no other way to get files extracted on the device. You have to place 
> them there, manually.
> 
> - Jon
> 
> _______________________________________________
> 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