Get resources xml file from url in JAVA












0















Currently I am storing my resources files on local directory and I am calling them by:



Resources res = getResources();
final String docukrz = res.getStringArray(R.array.docukrz);


I wanted to move this online, so I have created a url: https://example/strings.xml



Now how I can get that file so I will call it from URL, not resources folder.



I am a total beginner and read a lot of different articles and tutorials but cannot pull that together. Sorry if that is a duplicate.










share|improve this question


















  • 1





    The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

    – Ali
    Nov 14 '18 at 0:52











  • I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

    – Lukas
    Nov 14 '18 at 7:42











  • Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

    – Lukas
    Nov 14 '18 at 10:22


















0















Currently I am storing my resources files on local directory and I am calling them by:



Resources res = getResources();
final String docukrz = res.getStringArray(R.array.docukrz);


I wanted to move this online, so I have created a url: https://example/strings.xml



Now how I can get that file so I will call it from URL, not resources folder.



I am a total beginner and read a lot of different articles and tutorials but cannot pull that together. Sorry if that is a duplicate.










share|improve this question


















  • 1





    The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

    – Ali
    Nov 14 '18 at 0:52











  • I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

    – Lukas
    Nov 14 '18 at 7:42











  • Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

    – Lukas
    Nov 14 '18 at 10:22
















0












0








0








Currently I am storing my resources files on local directory and I am calling them by:



Resources res = getResources();
final String docukrz = res.getStringArray(R.array.docukrz);


I wanted to move this online, so I have created a url: https://example/strings.xml



Now how I can get that file so I will call it from URL, not resources folder.



I am a total beginner and read a lot of different articles and tutorials but cannot pull that together. Sorry if that is a duplicate.










share|improve this question














Currently I am storing my resources files on local directory and I am calling them by:



Resources res = getResources();
final String docukrz = res.getStringArray(R.array.docukrz);


I wanted to move this online, so I have created a url: https://example/strings.xml



Now how I can get that file so I will call it from URL, not resources folder.



I am a total beginner and read a lot of different articles and tutorials but cannot pull that together. Sorry if that is a duplicate.







java android xml






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 0:47









LukasLukas

72119




72119








  • 1





    The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

    – Ali
    Nov 14 '18 at 0:52











  • I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

    – Lukas
    Nov 14 '18 at 7:42











  • Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

    – Lukas
    Nov 14 '18 at 10:22
















  • 1





    The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

    – Ali
    Nov 14 '18 at 0:52











  • I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

    – Lukas
    Nov 14 '18 at 7:42











  • Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

    – Lukas
    Nov 14 '18 at 10:22










1




1





The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

– Ali
Nov 14 '18 at 0:52





The ID's in R.class are generated at compile time as int's. So, technically this is not possible. Perhaps if you can explain why you want to get the strings from Resources and not just your own object, we can help.

– Ali
Nov 14 '18 at 0:52













I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

– Lukas
Nov 14 '18 at 7:42





I would like to use the file the same way I am using it from resources, but instead storing it online. That is a String file, so i want to create some arrays containing strings from that file.

– Lukas
Nov 14 '18 at 7:42













Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

– Lukas
Nov 14 '18 at 10:22







Should I use this tutorial? docs.oracle.com/javase/tutorial/networking/urls/… All of it looks really complicated, and I thought this would be quite easy, but the more I read and ask the more questions I have. Maybe it is better to keep the xml file in my resources and just release a new version of the app whenever I will like to update it? It is just 1 simple file with strings.

– Lukas
Nov 14 '18 at 10:22














2 Answers
2






active

oldest

votes


















3














That is not how resources work. The resources framework is built around local storage, a specific set of directories and "qualifiers", and runtime determination of which resources should be available from the app.



You are welcome to download an xml file from the internet and parse it, but this will never be part of your app's resources.






share|improve this answer
























  • Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

    – Lukas
    Nov 14 '18 at 9:20



















1














I can suggest you use Retrofit and Kripton (I'm the author of this library) libraries to download an XML file from a URL and convert it into a Java object (or objects).



The wiki page of Kripton tries to explain how to do: instead of use JSON parser, you need to use XMLParser:



// create retrofit using Kripton converter factory
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(“https://jsonplaceholder.typicode.com/")
.addConverterFactory(KriptonBinderConverterFactory.create(BinderType.XML))
.build();
JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
// consume service
Response<List<Post>> response = service.getAllPost().execute();


More information about Retrofit and Kripton Persistence Library:




  • Retrofit

  • Kripton Persistence Library


If you want to see a working example using Retrofit and Kripton Persistence Library, you can see my example app RSS Reader on GitHub.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291597%2fget-resources-xml-file-from-url-in-java%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    That is not how resources work. The resources framework is built around local storage, a specific set of directories and "qualifiers", and runtime determination of which resources should be available from the app.



    You are welcome to download an xml file from the internet and parse it, but this will never be part of your app's resources.






    share|improve this answer
























    • Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

      – Lukas
      Nov 14 '18 at 9:20
















    3














    That is not how resources work. The resources framework is built around local storage, a specific set of directories and "qualifiers", and runtime determination of which resources should be available from the app.



    You are welcome to download an xml file from the internet and parse it, but this will never be part of your app's resources.






    share|improve this answer
























    • Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

      – Lukas
      Nov 14 '18 at 9:20














    3












    3








    3







    That is not how resources work. The resources framework is built around local storage, a specific set of directories and "qualifiers", and runtime determination of which resources should be available from the app.



    You are welcome to download an xml file from the internet and parse it, but this will never be part of your app's resources.






    share|improve this answer













    That is not how resources work. The resources framework is built around local storage, a specific set of directories and "qualifiers", and runtime determination of which resources should be available from the app.



    You are welcome to download an xml file from the internet and parse it, but this will never be part of your app's resources.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 '18 at 0:53









    Ben P.Ben P.

    23.6k32049




    23.6k32049













    • Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

      – Lukas
      Nov 14 '18 at 9:20



















    • Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

      – Lukas
      Nov 14 '18 at 9:20

















    Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

    – Lukas
    Nov 14 '18 at 9:20





    Thank you for your comment. If I will parse it from URL, can I create a String Array from the URL? URL link leads to an xml file actually.

    – Lukas
    Nov 14 '18 at 9:20













    1














    I can suggest you use Retrofit and Kripton (I'm the author of this library) libraries to download an XML file from a URL and convert it into a Java object (or objects).



    The wiki page of Kripton tries to explain how to do: instead of use JSON parser, you need to use XMLParser:



    // create retrofit using Kripton converter factory
    Retrofit retrofit = new Retrofit.Builder()
    .baseUrl(“https://jsonplaceholder.typicode.com/")
    .addConverterFactory(KriptonBinderConverterFactory.create(BinderType.XML))
    .build();
    JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
    // consume service
    Response<List<Post>> response = service.getAllPost().execute();


    More information about Retrofit and Kripton Persistence Library:




    • Retrofit

    • Kripton Persistence Library


    If you want to see a working example using Retrofit and Kripton Persistence Library, you can see my example app RSS Reader on GitHub.






    share|improve this answer




























      1














      I can suggest you use Retrofit and Kripton (I'm the author of this library) libraries to download an XML file from a URL and convert it into a Java object (or objects).



      The wiki page of Kripton tries to explain how to do: instead of use JSON parser, you need to use XMLParser:



      // create retrofit using Kripton converter factory
      Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(“https://jsonplaceholder.typicode.com/")
      .addConverterFactory(KriptonBinderConverterFactory.create(BinderType.XML))
      .build();
      JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
      // consume service
      Response<List<Post>> response = service.getAllPost().execute();


      More information about Retrofit and Kripton Persistence Library:




      • Retrofit

      • Kripton Persistence Library


      If you want to see a working example using Retrofit and Kripton Persistence Library, you can see my example app RSS Reader on GitHub.






      share|improve this answer


























        1












        1








        1







        I can suggest you use Retrofit and Kripton (I'm the author of this library) libraries to download an XML file from a URL and convert it into a Java object (or objects).



        The wiki page of Kripton tries to explain how to do: instead of use JSON parser, you need to use XMLParser:



        // create retrofit using Kripton converter factory
        Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(“https://jsonplaceholder.typicode.com/")
        .addConverterFactory(KriptonBinderConverterFactory.create(BinderType.XML))
        .build();
        JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
        // consume service
        Response<List<Post>> response = service.getAllPost().execute();


        More information about Retrofit and Kripton Persistence Library:




        • Retrofit

        • Kripton Persistence Library


        If you want to see a working example using Retrofit and Kripton Persistence Library, you can see my example app RSS Reader on GitHub.






        share|improve this answer













        I can suggest you use Retrofit and Kripton (I'm the author of this library) libraries to download an XML file from a URL and convert it into a Java object (or objects).



        The wiki page of Kripton tries to explain how to do: instead of use JSON parser, you need to use XMLParser:



        // create retrofit using Kripton converter factory
        Retrofit retrofit = new Retrofit.Builder()
        .baseUrl(“https://jsonplaceholder.typicode.com/")
        .addConverterFactory(KriptonBinderConverterFactory.create(BinderType.XML))
        .build();
        JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
        // consume service
        Response<List<Post>> response = service.getAllPost().execute();


        More information about Retrofit and Kripton Persistence Library:




        • Retrofit

        • Kripton Persistence Library


        If you want to see a working example using Retrofit and Kripton Persistence Library, you can see my example app RSS Reader on GitHub.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 1:03









        xcescoxcesco

        1,9391533




        1,9391533






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291597%2fget-resources-xml-file-from-url-in-java%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python