[android-developers] Shared Preferences file size

2016-07-29 Thread praveen singh
How can we calculate total size of preferences file size in a app?
Is there any size limit for Shared preferences file in android?

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/f5a80950-969c-4f0a-b8da-4da164b8852e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Shared Preferences

2012-10-11 Thread Mark Murphy
On Thu, Oct 11, 2012 at 10:13 AM, Mario Bat  wrote:
> Hi, what is the difference betweent
> PreferenceManager.getDefaultSharedPreferences and
> getSahredPreferences(String name, int mode) ?

The first is the default (e.g., what PreferenceActivity will use). The
second uses a name that you supply.

> I thought that the defaultSharedPreferences are someting like global
> preferences that every application can manipulate.

No, all SharedPreferences are local to an app, by default.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.2 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Shared Preferences

2012-10-11 Thread Mario Bat
Hi, what is the difference betweent 
PreferenceManager.getDefaultSharedPreferences and 
getSahredPreferences(String name, int mode) ?

I thought that the defaultSharedPreferences are someting like global 
preferences that every application can manipulate. So lets say that I can 
call a preference from another application in my own application, and even 
change it.
And the getSharedPreferences are preferences that I can only use in my 
application.

Thats just what I thougt it is...but I'm not sure.


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Shared Preferences

2012-02-07 Thread poncho

Hi,

The code itself is fine except that you don't print the exception.

If you would log the exception you can see (in the LogCat) that the 
run-time is throwing some kind of a ParseException.
This is since users (usually) don't type 'L' at the end of their numeric 
input, even when it's long.


Hope this helps
/Poncho

On 02/07/2012 02:54 PM, ajay talreja wrote:

This code is not working for mei'm trying to use Shared
preferences to store long values.the code is correct and is
launching successfully when i switch from long to int valuesplease
help


package d.preferencesdemo1;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class preferencesdemo1 extends Activity {
 /** Called when the activity is first created. */
EditText t;
  long mobileno;
  TextView text;
 SharedPreferences app_preferences;
 @Override
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 // Get the app's shared preferences
 app_preferences =
PreferenceManager.getDefaultSharedPreferences(this);

 mobileno = app_preferences.getLong("mobileno",9028252169L);

 // Update the TextView
 text = (TextView) findViewById(R.id.text);
 text.setText("The default mobile number is " + mobileno +
".");

 // Increment the mobileno
  //   SharedPreferences.Editor editor = app_preferences.edit();
// editor.putlong("mobileno", ++mobileno);
 //editor.commit(); // Very important


 t = (EditText) findViewById(R.id.EditText01);

 Button b2 = (Button) findViewById(R.id.Button01);
 t.setText("");


b2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {

   try {
// Increment the mobileno
   SharedPreferences.Editor editor =
app_preferences.edit();
   long tv =
Long.parseLong(t.getText().toString());
   mobileno=tv;
   editor.putLong("mobileno", mobileno);
   editor.commit(); // Very important



   text.setText("The default mobile number is "
+ mobileno + ".");

   }
   catch (Exception e) {

   }
}
});

 }
}



--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Shared Preferences

2012-02-07 Thread ajay talreja
This code is not working for mei'm trying to use Shared
preferences to store long values.the code is correct and is
launching successfully when i switch from long to int valuesplease
help


package d.preferencesdemo1;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class preferencesdemo1 extends Activity {
/** Called when the activity is first created. */
EditText t;
  long mobileno;
  TextView text;
 SharedPreferences app_preferences;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Get the app's shared preferences
app_preferences =
PreferenceManager.getDefaultSharedPreferences(this);

mobileno = app_preferences.getLong("mobileno",9028252169L);

// Update the TextView
text = (TextView) findViewById(R.id.text);
text.setText("The default mobile number is " + mobileno +
".");

// Increment the mobileno
 //   SharedPreferences.Editor editor = app_preferences.edit();
   // editor.putlong("mobileno", ++mobileno);
//editor.commit(); // Very important


t = (EditText) findViewById(R.id.EditText01);

Button b2 = (Button) findViewById(R.id.Button01);
t.setText("");


   b2.setOnClickListener(new View.OnClickListener() {
   public void onClick(View view) {

  try {
// Increment the mobileno
  SharedPreferences.Editor editor =
app_preferences.edit();
  long tv =
Long.parseLong(t.getText().toString());
  mobileno=tv;
  editor.putLong("mobileno", mobileno);
  editor.commit(); // Very important



  text.setText("The default mobile number is "
+ mobileno + ".");

  }
  catch (Exception e) {

  }
   }
   });

}
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Shared preferences and integer values

2011-08-13 Thread Appaholics
Most probably your Int_Value doesn't exist. In this case the number you
specified, 200, will be assigned instead.

Thanks

On Sat, Aug 13, 2011 at 12:52 PM, Kristoffer wrote:

> Hello.
>
> Iam using shared preferences to store some values.
>
> final SharedPreferences pref = getSharedPreferences("MyPref",
> MODE_PRIVATE);
>
> final SharedPreferences.Editor edit = pref.edit();
>
> edit.putInt("Int_value", 1);
> edit.putString("String_Value", "test string");
> edit.commit();
>
>
> i look in the xml file and everything is saves as it should.
>
> now i grabb the values:
>
> int i = pref.getInt("Int_Value", 200);
> String s = pref.getString("String_Value", "");
>
> and now i wanna add it to a text label:
>
> I have this in top of my code
>
> final TextView test = (TextView) findViewById(R.id.test);
>
> and then if i wanna show the string everything works as it should.
>
> test.setText(s);
>
> if i try to show the int value with this
>
> test.setText(i);
>
> then my application make a force close, so i thougt that the problem
> was that i had to make the int a string so i did like this
>
>  test.setText(Integer.toString(i));
>
> now the program wotk but it does not show my stored value it shows me
> the in this case 200 becourse of
>
> int i = pref.getInt("Int_Value", 200);
>
> I must be missing something simple here i quess.
> could someone point it out for me?
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 

Raghav Sood
CEO/Founder/Owner/Dictator/Tyrant at Appaholics (Basically all titles
required to have complete control)
http://www.raghavsood.com/
https://market.android.com/developer?pub=Appaholics
http://www.appaholics.in/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Shared preferences and integer values

2011-08-13 Thread Kristoffer
Hello.

Iam using shared preferences to store some values.

final SharedPreferences pref = getSharedPreferences("MyPref",
MODE_PRIVATE);

final SharedPreferences.Editor edit = pref.edit();

edit.putInt("Int_value", 1);
edit.putString("String_Value", "test string");
edit.commit();


i look in the xml file and everything is saves as it should.

now i grabb the values:

int i = pref.getInt("Int_Value", 200);
String s = pref.getString("String_Value", "");

and now i wanna add it to a text label:

I have this in top of my code

final TextView test = (TextView) findViewById(R.id.test);

and then if i wanna show the string everything works as it should.

test.setText(s);

if i try to show the int value with this

test.setText(i);

then my application make a force close, so i thougt that the problem
was that i had to make the int a string so i did like this

 test.setText(Integer.toString(i));

now the program wotk but it does not show my stored value it shows me
the in this case 200 becourse of

int i = pref.getInt("Int_Value", 200);

I must be missing something simple here i quess.
could someone point it out for me?



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Shared preferences in a library

2010-10-29 Thread TreKing
On Tue, Oct 26, 2010 at 8:59 AM, BlackNeko  wrote:

>  Now, I want to use the shared preferences to get some settings and use
> them for doing calculations in my lib, and I've been trying but can't
> get a valid context to use in getDefaultSharedPreferences(). Any ideas?
>

public Library(*Context context*) {
   SharedPreferences settings =
PreferenceManager.
getDefaultSharedPreferences(*context*);
   someVar = settings.getInt("someVar", 435);
   }

   public int otherMethodes(){
   return someVar; //not important
   }
}

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Shared preferences in a library

2010-10-28 Thread BlackNeko
I made a library that I access and use across my app.

My code looks something like this:

package com.android.foobar;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Library{
int someVar;

public Library() {
SharedPreferences settings =
PreferenceManager.getDefaultSharedPreferences(this);
someVar = settings.getInt("someVar", 435);
}

public int otherMethodes(){
return someVar; //not important
}
}
--

Now, I want to use the shared preferences to get some settings and use
them for doing calculations in my lib, and I've been trying but can't
get a valid context to use in getDefaultSharedPreferences(). Any ideas?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Shared preferences not accessible in service

2009-03-03 Thread Shadakshari Hiremath

Hello Android,

We are using SharedPreferences(Not default preferences.) to store our
application related settings. These settings are not accessible in the
background service as the application context is different from
service context. It always returns the default values. We want to have
our own UI to manage settings. So, we don't want to use
PreferenceActivity.

Is there a way or hack to access SharedPreferences from inside a
service which are created by application?

BR,
Shaddu

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] shared preferences between applications

2008-11-14 Thread Jason Proctor

i'm using java.util.prefs.Preferences to maintain my apps' 
preferences, but it seems like one app can't read another's 
preferences, even if the path to them is the same. is this intended? 
should i be using a different root than userRoot() ?

tx

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---