Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:09:27+00:00 2026-05-22T12:09:27+00:00

If so, is there a tutorial that I have missed somewhere that might help

  • 0

If so, is there a tutorial that I have missed somewhere that might help me get started with this? If not, can someone point me towards a place to get started setting up a database where I would preload the information instead of actually having the user do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:09:28+00:00Added an answer on May 22, 2026 at 12:09 pm

    Here’s a simple example of loading values from a values xml file into a string array, searching through the values, and selecting one for display.

    values/strings.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string
            name="hello">Hello World, Main!</string>
        <string
            name="app_name">Q6024120_Load_And_Search_Array</string>
        <string-array
            name="planets_array">
            <item>Mercury</item>
            <item>Venus</item>
            <item>Earth</item>
            <item>Mars</item>
            <item>Jupiter</item>
            <item>Saturn</item>
            <item>Uranus</item>
            <item>Neptune</item>
        </string-array>
    </resources>
    public class Main extends Activity
    {
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        String[] planets = getResources().getStringArray(R.array.planets_array);
        int foundIndex = -1;
        for (int i = 0; i < planets.length; i++)
        {
          String planet = planets[i];
          if (planet.equals("Mars"))
          {
            foundIndex = i;
            break;
          }
        }
        String foundPlanet = foundIndex >= 0 ? planets[foundIndex] : "nothing";
        ((TextView)findViewById(R.id.found_planet)).setText("found: " + foundPlanet);
      }
    }

    If you’d rather load the data from an xml file in the assets folder, note that it’s a bit involved. Take a look at android: how to load xml file from assets directory?.

    If the values are just a simple list of strings, then xml structure probably isn’t necessary. Here’s a simple example of loading the values from a text file in the assets folder.

    assets/planets.txt

    Mercury
    Venus
    Earth
    Mars
    Jupiter
    Saturn
    Uranus
    Neptune
    public class Main extends Activity
    {
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        // String[] planets = getResources().getStringArray(R.array.planets_array);
        String[] planets = readFromAssetsTxt();
        int foundIndex = -1;
        for (int i = 0; i < planets.length; i++)
        {
          String planet = planets[i];
          if (planet.equals("Mars"))
          {
            foundIndex = i;
            break;
          }
        }
        String foundPlanet = foundIndex >= 0 ? planets[foundIndex] : "nothing";
        ((TextView) findViewById(R.id.found_planet)).setText("found: " + foundPlanet);
      }
    
      String[] readFromAssetsTxt()
      {
        try
        {
          AssetManager assetManager = getAssets();
          List<String> planets = new ArrayList<String>();
          BufferedReader in = new BufferedReader(new InputStreamReader(assetManager.open("planets.txt")));
          String planet = null;
          while ((planet = in.readLine()) != null)
          {
            planets.add(planet);
          }
          in.close();
          String[] planetsArray = new String[planets.size()];
          planets.toArray(planetsArray);
          return planetsArray;
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
        return new String[] {};
      }
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any book or links that I can read some tutorial about the
Is there a good tutorial or does anyone have experience with setting this up
Ok while watching a tutorial I stupidly missed the part that you have to
In every JavaScript tutorial that I have looked there is something mentioned about a
Is there a .NET library/tutorial available that will let me show me how to
I have seen a tutorial that has the following JSON: { books:[{title:frankenstein},{title:Moby Dick}] }
I have an IEnumerable(of Employee) with a ParentID/ChildID relationship with itself that I can
Hey there, I'm using the tutorial at http://www.jamesfairhurst.co.uk/posts/view/uploading_files_and_images_with_cakephp to try to get myself up
Assume that I have a java file, how can I wrap it into a
I am developing apps for ios and android sdk. Is there any tutorial that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.