Exercise 1 MyTunes- Intro to Cross Platforms XAM110

aisacaisac DEMember ✭✭

Hello,
I am working on the application MyTunes from the XAM110 classes.
I was thinking about to change my FileName string so I can get the string filename from my Strings.xml file

SongLoader.cs code:

namespace MyTunes
{
    public static class SongLoader
    {
        const string Filename = "songs.json";

        public static async Task> Load()
        {
            using (var reader = new StreamReader(OpenData()))
            {
                return JsonConvert.DeserializeObject>(await reader.ReadToEndAsync());
            }
        }

        private static Stream OpenData()
        {
#if __ANDROID__
            return Android.App.Application.Context.Assets.Open(Filename);
#else
            // TODO: add code to open file here.
            return null;
#endif
        }
    }
}

SongLoader.cs code EDITED:

namespace MyTunes
{
    public static class SongLoader
    {
        const string Filename = "@string/Filename";

        public static async Task> Load()
        {
            using (var reader = new StreamReader(OpenData()))
            {
                return JsonConvert.DeserializeObject>(await reader.ReadToEndAsync());
            }
        }

        private static Stream OpenData()
        {
#if __ANDROID__
            return Android.App.Application.Context.Assets.Open(Filename);
#else
            // TODO: add code to open file here.
            return null;
#endif
        }
    }
}

Thanks

Answers

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    And? You haven't asked a question, so we don't know what we're supposed to tell you.

    If you're asking how to retrieve the filename from an xml file, look through the Guides, Samples, and API docs for information on XML. If you have specific questions, come back and ask them.

    We're not going to write the code for you.

  • aisacaisac DEMember ✭✭

    My question was " can I get my Filename from my Strings.xml file?"
    Well...I am not seeing the part where I asked for the code, just wanted to show how I did ( See code EDITED)
    I will carefully take a look on the links you sent.

    Thank you

Sign In or Register to comment.