简体   繁体   中英

How i can load the updated xml file in my project solution from app directory that is from my phone

i have changed the XML attribute and save the XML file the file is save in App directory in phone path is "Android/data/data/App17.App17/files" Now i want to load this updated XML file in my project how can i do this

namespace App17
{
    [Activity(Label = "App17", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var xml = XDocument.Load(Assets.Open("Q317664.xml"));
            var node = xml.Descendants("Book").FirstOrDefault(cd =>        cd.Attribute("Id").Value == "1");
            node.SetAttributeValue("ISBN", "new");

            string dir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            string path = Path.Combine(dir, "Q317664.xml");
        }
    }
}
var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var filename = Path.Combine(path, "Q317664.xml");

var xmlString=File.ReadAllText(filename);
XDocument doc = XDocument.Parse(xmlString);

XML will be loaded to doc instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM