Hi,
Sorry for not reply earlier, since I was at a Lenovo Hackthon.
The C: was a cut and paste error. You should use
pathToSave =
Environment.GetFolderPath(Environment.SpecialFolder.Personal)
which will give you the /data/data/AndroidPackageName/ directory
Just select the file as a Embedded Resources (Not Android
Resources) and use the following (Normal Resource Handling ) to
retrieve the file
string[] resNames =
resourceAssembly.GetManifestResourceNames();
//Process the resource names from the manifest
foreach (string resName in resNames)
{
if
(resName.ToLower().Contains(fullResourcePattern.ToLower()) == true)
{
}
}
Hope this helps
Best Regards,
Sridharan Srinivasan
On Fri, Sep 16, 2011 at 1:59 AM, Mittchel Van Vliet <[email protected]> wrote:
> Hi,
> Thanks for your reply,
> I do have a question regarding your example; The "C:\\Path\\To\\File" means
> the path to the file on my computer right? But why's that neccesary when you
> save it in your assets folder?
> Further; I'm definitely going to exceed the 1MB limit.. so how does the
> Resources option work? haha:P
> Thanks!
>
> 2011/9/15 SRI <[email protected]>
>>
>> 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 <[email protected]>
>> 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
>> > [email protected]
>> >
>> > UNSUBSCRIBE INFORMATION:
>> > http://lists.ximian.com/mailman/listinfo/monodroid
>> >
>> >
>>
>>
>>
>> --
>> Sridharan Srinivasan
>> Alias Sri
>> Ph:(65)98255785/(65)63922439
>> www.arshu.com
>> _______________________________________________
>> Monodroid mailing list
>> [email protected]
>>
>> UNSUBSCRIBE INFORMATION:
>> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
> _______________________________________________
> Monodroid mailing list
> [email protected]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
--
Sridharan Srinivasan
Alias Sri
Ph:(65)98255785/(65)63922439
www.arshu.com
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid