Home

Awesome

Ultimate String-Array List

Feature Image

As an Android developer, I absolutely hate it when I have to worry about getting data for common use cases which involve things like list of countries, list of states or even letting the users enter their birth year. We see this in most android apps, especially the ones which have a form that a user needs to fill. Even if I do find the data , it is hardly in a format that I can use easily in my app. Honestly, this is :poop:!

So I decided to do this :poop: work for you :smile:! This repo will be a comprehensive list of common use cases like these with data in a format which is extremely easy to use in an Android app.

We have enough things to worry about as an Android developer and collecting data for common use cases shouldn't be one of them!

Current List of String-Arrays

The repository has the following list of string-array. Please note that this is continuously being updated so do check frequently. You can also send in your requests via the issue tracker. I am hoping that you take some inspiration from the categories I am adding and make contributions to this repo to make it more useful.

NameDescription
App Categories.xmlList of app categories present on the Google Play Store
AWS Regions.xmlList of codes and names for AWS region
Canada Province Codes.xmlList of codes of provinces in Canada
Canada Provinces.xmlList of provinces in Canada
China Province Codes.xmlList of codes of provinces in China
China Provinces.xmlList of provinces in China
Cloud_providers.xmlList of major public cloud providers
Countries.xmlList of all countries in the world
Country telephone and iso codes.xmlList of countries with their telephone codes.
Credit Card Companies.xmlList of credit card networks
Cuisine.xmlList of the different types of cuisines that people eat
Days of Month.xmlList of days possible in a month
Days Of Week.xmlList of days within a week
Elements.xmlList of chemical elements
EPL Clubs.xmlList of EPL Clubs(Season 22-23)
Gender.xmlList of the possible gender options
Genre.xmlList of the different genres of music
India Banks.xmlList of all the banks running in India
India Top Cities.xmlList of top cities in India
India State Codes.xmlList of codes of States in India
India States.xmlList of States in India
Months.xmlList of all the possible months of a year
Moods.xmlList of the different moods of people
Mumbai Localities.xmlList of the localities of Mumbai
Olympic Countries.xmlList of countries participating in the 2016 Olympics
Olympic Sports.xmlList of the different sports being played in 2016 Olympics
Presidents.xmlList of United states of America presidents
Seasons.xmlList of the possible season of a year
Sex.xmlList of different sex categories (You have a disgusting mind :smile:)
Timezones.xmlList of time zones
US State Codes.xmlList of codes of States in the US
US States.xmlList of States in the US
Weather.xmlList of different weather conditions
world_cup_2022_groups.xmlList of countries in Qatar 2022 world cup
world_spoken_languages.xmlList of some world languages
Years.xmlList of years from 1900 to 2050

Why String-Arrays?

String-Arrays are extremely flexible to use and it is very easy to use them in any data structure that we might like. Don't believe me? Fine let me prove it to you!

Copy the string array you want to use and place it in the res/values/some_file_name.xml file. It would look something like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="months">
        <item>January</item>
        .
        .
        .
    </string-array>
</resources>

Now to access this programmatically, we can do this:

//Get it in an array of strings
String[] months = getResources().getStringArray(R.array.months);

//Convert it into a list
List<String> monthsList = new ArrayList<String>();
    list = Arrays.asList(months);

You can also combine these string arrays for use in your apps. Let's say I want a key-value pair with the state codes as the key and the state names as the value. To implement this, I can do the following:

String[] us_state_codes = getResources().getStringArray(R.array.us_state_codes);


String[] us_state = getResources().getStringArray(R.array.us_states);

final Map<String, String> m = new HashMap<String, String>();

for(int i=0;i<us_state_codes.length();i++){
  m.put(us_state_codes[i],us_states[i]);
}

As you can see, this is a really flexible way to access data and can be used in various scenarios.

Note: This is extremely basic stuff but I wanted to show these examples for people who have not worked with string-arrays before.

Contributing

Please use the issue tracker to report any discrepancies in the data or any string-arrays you would like to see.

For contributions to this repo, fell free to send a pull request.

Credits

Author: Vinay Gaba (vinaygaba@gmail.com)

<a href="https://plus.google.com/+Vinaygaba"> <img alt="Follow me on Google+" src="https://github.com/gabrielemariotti/cardslib/raw/master/demo/images/g+64.png" /> </a> <a href="https://twitter.com/vinaygaba"> <img alt="Follow me on Twitter" src="https://github.com/gabrielemariotti/cardslib/raw/master/demo/images/twitter64.png" /> </a> <a href="https://www.linkedin.com/in/vinaygaba"> <img alt="Follow me on LinkedIn" src="https://github.com/gabrielemariotti/cardslib/raw/master/demo/images/linkedin.png" /> </a>

License

Copyright 2015 Vinay Gaba

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.