Post Reply

Shared preferences and textview

OP mistere372002

16th March 2014, 07:35 PM   |  #1  
mistere372002's Avatar
OP Senior Member
Flag Tucson
Thanks Meter: 51
 
228 posts
Join Date:Joined: May 2010
More
I originally asked this question in Srackoverflow. But I did not get any answers.

I am trying to set a text view number value to shared preferences using a string to get the values. Can anyone help with this?

Sent from my SGH-M919 using XDA Premium 4 mobile app
16th March 2014, 08:43 PM   |  #2  
Junior Member
Thanks Meter: 2
 
13 posts
Join Date:Joined: Feb 2013
Quote:
Originally Posted by mistere372002

I am trying to set a text view number value to shared preferences using a string to get the values

Could you elaborate on this?
You want to store the text (which is a number) in the textview to shared preferences?

Code:
  mPrefs.edit().putInt("my-key", Integer.parse(mTextView.getText().toString())).commit();
16th March 2014, 10:52 PM   |  #3  
mistere372002's Avatar
OP Senior Member
Flag Tucson
Thanks Meter: 51
 
228 posts
Join Date:Joined: May 2010
More
That's correct. I forgot to mention that the number could be a decimal also.

Sent from my SGH-M919 using XDA Premium 4 mobile app
Last edited by mistere372002; 16th March 2014 at 11:05 PM.
17th March 2014, 02:15 PM   |  #4  
mistere372002's Avatar
OP Senior Member
Flag Tucson
Thanks Meter: 51
 
228 posts
Join Date:Joined: May 2010
More
Thanks painless, that worked perfectly!

Sent from my SGH-M919 using XDA Premium 4 mobile app
19th March 2014, 12:16 AM   |  #5  
Junior Member
Thanks Meter: 0
 
15 posts
Join Date:Joined: Dec 2013
Storing Chronometer time in SharedPreferences
Quote:
Originally Posted by mistere372002

Thanks painless, that worked perfectly!

Sent from my SGH-M919 using XDA Premium 4 mobile app

I am actually trying to store the value of a chronometer in SharedPreferences but admittedly I have not worked with SharedPreferences much.

My end goal is to be able to close the Chronometer app and have the chronometer pick up from where it left off when the app is close.

Any help is appreciated.



Code:
 chronometer = (Chronometer) findViewById(R.id.Chronometer1);

public void startClick (View view){
    	 	
    
    	
    	
    	 chronometer.setBase(SystemClock.elapsedRealtime());
         chronometer.start();
         Vibrator vib = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
 		vib.vibrate(100);
        }
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Android Software Development by ThreadRank