Hi,

          You can use like this

           using (System.IO.Stream dbStream = Assets.Open(items.db3))
          {
                 using (var fileStream = File.Create("C:\\Path\\To\\File"))
                 {
                       appStream.CopyTo(fileStream);
                 }
          }

          Points to Note the db3 file size should not exceed 1 MB else
uncompression in Android hits error.

          You can also use Embedded Resources which does not have this
limitation.

Hope this helps

Best Regards,
Sridharan Srinivasan

On Thu, Sep 15, 2011 at 8:26 PM, Mittchel Van Vliet <mittc...@gmail.com> wrote:
> Hello everyone,
> I recently started exploring around with Monodroid and now I wanted to work
> with databases.
> Finally I got that working, but what I want now is I made an database with
> SQLite database browser.. and I want that file(database) to be deployed onto
> the machine so that I can use the already existing data inside that
> database.. but how do I get that to work from scratch?
> Someone told me about Assets but how do I get the path of the asset file?
> I've got the following to connect to a database now:
>         public static SqliteConnection GetConnection()
>         {
>             var documents =
> System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
>             string db = Path.Combine(documents, "items.db3");
>             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', 'text1')",
>                     "INSERT INTO [Items] ([Key], [Value]) VALUES ('sample2',
> 'text2')",
>                     "INSERT INTO [Items] ([Key], [Value]) VALUES ('sample3',
> 'text3')",
> };
>                 foreach (var cmd in commands)
>                     WithCommand(c =>
>                     {
>                         c.CommandText = cmd;
>                         c.ExecuteNonQuery();
>                     });
>             }
>             return conn;
>         }
>
>
> Thanks in advance,
> -- Mittchel
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>



-- 
Sridharan Srinivasan
Alias Sri
Ph:(65)98255785/(65)63922439
www.arshu.com
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

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

Reply via email to