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

  • Home
  • SEARCH
  • 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 7562643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:27:37+00:00 2026-05-30T13:27:37+00:00

i am trying to select an item using Spinners. I have a JSON file

  • 0

i am trying to select an item using Spinners. I have a JSON file stored in asset Folder. I want to select an item from spinner and then get its numeric value stored in my JSON File. and then store this numeric value in database. Please tell me how can i implement this

Best Regards

  • 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-30T13:27:38+00:00Added an answer on May 30, 2026 at 1:27 pm

    You need an Adapter for your Spinner. See here http://developer.android.com/resources/tutorials/views/hello-spinner.html

    That adapter will hold the values you select using your spinner.
    If these are some fixed values then ArrayAdapter can do. You can fill it with values like follows:

    public YourActivity extends Activity {
    ...
    private String[] mValues = {"One", "Two", "Three"};
    private Spinner mSpinner;
    public void onCreate(Bundle bundle) {
    ...
    mSpinner = findViewById(R.id.yourspinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(
       this, android.R.layout.simple_spinner_item, mValues);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mSpinner.setAdapter(adapter);
    ...
    }
    

    After this you will have a spinner populated with mValues. (Alternatively, you can use ArrayAdapter.createFromResource).

    Then, you will have to read your assets file using something like

    InputStream is = getAssets().open("your_asset.txt");
    

    For assets see here http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/content/ReadAsset.html

    You’ll probably need to parse the input stream using JSON parser. I believe Android has a JSON parser class. See for example here http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/
    Oh, yes, as posted in the answer below by Anil it’s enough to parse the JSON file only once.

    Then you need to store the value you found for your spinner element in the database. This gets long to to explain. You can see how to create and use databases in Android docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I selected some item in combobox and then I'm trying to select another
I'm trying to return 'ItemId' column value of 'item' table using stored procedure based
I am using mechanize and I am trying to select a button from a
I've been trying to select an item on an external listview but it seems
In trying to select elements that have any attributes, the following throws a jQuery
I'm trying to select data from a table defined similar to the following :
I'm trying to select a random 10% sampling from a small table. I thought
I'm trying to select a column from a single table (no joins) and I
I'm trying to select the used range. I get the worksheet's UsedRange, then I
I'm trying to select a subgroup of a list where items have contiguous dates,

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.