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 4583680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:14:55+00:00 2026-05-21T21:14:55+00:00

I am fetching values from a number of text fields and storing their values

  • 0

I am fetching values from a number of text fields and storing their values in the corresponding preference values in my preference file. I dont know wat i am doing wrong. Here is my code:

public void onClick(View source) {
    switch(source.getId())
    {
    case R.id.imageButtonNext:
        String longitude=String.valueOf(editTextLongitude.getText());
        String latitude=String.valueOf(editTextLatitude.getText());
        String currentTime=String.valueOf(textViewCurrentTime.getText());
        String agentNo=String.valueOf(editTextAgentno.getText());
        String description=String.valueOf(editTextDescription.getText());
        String mobile_number=String.valueOf(editTextMobileNo.getText());
        moredetails=getSharedPreferences("prefs",0);
        SharedPreferences.Editor editor=moredetails.edit();
        editor.putString("latitude",latitude);
        editor.putString("longitude",longitude);
        editor.putString("currentTime",currentTime);
        editor.putString("agentNo",agentNo);
        editor.putString("description",description);
        editor.putString("mobileNo",mobile_number);

        String lat=moredetails.getString("latitude","");
        Toast.makeText(CurrentLocation.this,lat,Toast.LENGTH_LONG).show();
        break;
    }   
}

PREFERENCE FILE:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
  xmlns:android="http://schemas.android.com/apk/res/android">
    <Preference android:key="latitude" android:title="@string/latitudeString"></Preference>
    <Preference android:key="@string/longitudeString" android:title="@string/longitudeString"></Preference>
    <Preference android:key="@string/agentNoString" android:title="@string/agentNoString"></Preference>
    <Preference android:key="@string/assistantNameString" android:title="@string/assistantNameString"></Preference>
    <Preference android:key="@string/mobilenoString" android:title="@string/mobilenoString"></Preference>
    <Preference android:key="@string/cashFloatString" android:title="@string/cashFloatString"></Preference>
    <Preference android:key="@string/efloatString" android:title="@string/efloatString"></Preference>
    <Preference android:key="@string/posterAString" android:title="@string/posterAString"></Preference>
    <Preference android:key="@string/posterBString" android:title="@string/posterBString"></Preference>
    <Preference android:key="@string/smexnoString" android:title="@string/smexnoString"></Preference>
    <Preference android:key="@string/trainingString" android:title="@string/trainingString"></Preference>
    <Preference android:key="currentTime" android:title="currentTime"></Preference>
</PreferenceScreen>

I will really appreciate the help.

  • 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-21T21:14:55+00:00Added an answer on May 21, 2026 at 9:14 pm

    You need to call:

    editor.commit();
    

    after making your changes to commit and store them.

    You might also want to look at PreferenceActivity as this provides an awful lot of functionality out-of-the-box.

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

Sidebar

Related Questions

I'm using a JSON file which contains non-English characters.Hence when I'm fetching values from
I'm fetching some data from an MSSQL table using the mssql_fetch_object, but the text
How do I properly bubble sort through a text file by assigning the values
I am fetching some values from my DB. The columns are of float type
I have two tables tracklist and song. I am fetching all values from song
I have a problem fetching values from a MySQL cursor. I create a temporary
I have primefaces autocomplete which is fetching values from database. When I type in
I'm ceating an application with SQLite. When I'm fetching the values from the database,
I have tried fetching MySQL query results using mysql_fetch_row() and mysql_result() and numeric values
I am fetching two separate variables with time & date as separate values: $v['EventDate']

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.