1

If I have an activity, and I want that activity to get data from a stub file within the project and put it into an array, how would I do this?

At the moment I've used data which is hard coded into the activity using a setListAdapter making a new ArrayAdapter with the following building this array:

    static final String[] Food = new String[] {

        "Chips", "Fish"

    };

1 Answer 1

1

I think this tutorial should help you. It reads a file line by line and prints the content on the console. Instead of printing the content on the console, you should just add it to your array.

For example the line:

System.out.println(dis.readLine());

Could look like this:

food[0] = dis.readLine();

Btw... variable names in Java shouldn't be uppercase (Java Naming Convetions).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.