{"id":13,"date":"2013-12-23T10:48:18","date_gmt":"2013-12-23T10:48:18","guid":{"rendered":"http:\/\/en.nisi.ro\/blog\/?p=13"},"modified":"2014-07-13T19:02:41","modified_gmt":"2014-07-13T17:02:41","slug":"android-load-array-strings-resources","status":"publish","type":"post","link":"https:\/\/en.nisi.ro\/blog\/development\/java-android\/android-load-array-strings-resources\/","title":{"rendered":"Android: Load array of Strings from Resources"},"content":{"rendered":"<p>It is remanded to keep your strings in xml resources, but how do you get them as a String[] ?<\/p>\n<p><!--more--><br \/>\nSave as a xml file on your project &gt; res &gt; values &gt; mydata.xml<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;resources&gt;\r\n    &lt;string-array name=&quot;blogs&quot;&gt;\r\n        &lt;item&gt;http:\/\/www.google.com\/&lt;\/item&gt;\r\n        &lt;item&gt;http:\/\/www.yahoo.com\/&lt;\/item&gt;\r\n        &lt;item&gt;http:\/\/www.bing.com\/&lt;\/item&gt;\r\n    &lt;\/string-array&gt;\r\n&lt;\/resources&gt;\r\n<\/pre>\n<p>and from your source code<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/\/...\r\nResources res = this.getResources();\r\nString&#x5B;] myWebsitesArray= res.getStringArray(R.array.websites);\r\n\/\/...\r\n<\/pre>\n<p>that is it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is remanded to keep your strings in xml resources, but how do you get them as a String[] ?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[17,19,20,16,18],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-java-android","tag-android-development","tag-getresources","tag-getstringarray","tag-java","tag-resources"],"_links":{"self":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":2,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":76,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions\/76"}],"wp:attachment":[{"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/en.nisi.ro\/blog\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}