Re: [android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-16 Thread lselwd
 my problem solved but another problem arises:
used:
  // public constructor
   public CannonView(Context context, AttributeSet attrs)
   {
  super(context, attrs); // call super's constructor
  *activity = (Activity) context; *
.
..
SharedPreferences prefs = *activity.*getSharedPreferences("top5", 
MODE_PRIVATE);

well if i have (same app) an activity and a Canvas like:
*public class CannonView extends SurfaceView *
*   implements SurfaceHolder.Callback*
*{*
+
*public class CannonGame extends Activity*
*{*
And want record user name played what to do ... I use shared pref 
in CannonView to record 5 top scores... when used get username dialog 
success but in 
   public void onCreate(Bundle savedInstanceState)  // Activity
   {
  super.onCreate(savedInstanceState); // call super's onCreate method
  setContentView(R.layout.main); // inflate the layout
  //userName = insertUser() ; ///  line 104
  // get the CannonView
  cannonView = (CannonView) findViewById(R.id.cannonView);
  
  //cannonView.asignVars(userName);//insertUser()
  cannonView.userName=insertUser() ;

user is not recorded like non pass from Activity class (Main) to non 
Activity class(canvas)... well is it because execution moved to canvas or 
insertUser() may malfunction(thie latter not think so hence toast of user 
name show works), well? 


On Saturday, March 16, 2013 12:50:19 PM UTC+2, lselwd wrote:
>
>
> it seems i do not use context (in shared pref command)... i get it for an 
> activity... i will retry...
>
> context is optional inside an activity, correct?
>

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-16 Thread lselwd

it seems i do not use context (in shared pref command)... i get it for an 
activity... i will retry...

context is optional inside an activity, correct?

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-12 Thread Jayu Sagar
Try this piece of code


Isn't there a getContext() method for SurfaceView?

getContext().getSharedPreference();



Regards,
Jayanand


On Sat, Mar 9, 2013 at 4:26 PM, lselwd  wrote:

> public class CannonView extends SurfaceView
>implements SurfaceHolder.Callback
> {
>
>
> this is its class , of function
>
> On Saturday, March 9, 2013 11:43:08 AM UTC+2, lselwd wrote:
>>
>> I have problem working with SHARED PREFERENCES, I think is project
>> specific... i used the same before without errors but now get error see
>> attachments, well?
>>
>  --
> --
> 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
> ---
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-12 Thread Jayu Sagar
pass using intent while starting the activity



On Sat, Mar 9, 2013 at 6:38 PM, lselwd  wrote:

> In a Canvas game if we have a class like:
>
> *public class CannonView extends SurfaceView *
> *   implements SurfaceHolder.Callback*
> *{*
> how transfer from this a var value to this
> *public class CannonGame extends Activity*
> *{*
> without using static vars?
>
>  --
> --
> 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
> ---
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-10 Thread Seshu
Hi,
 If u r creating sharedpreferences in our activity class means
then it wont show any error other wise if u r creating shared
preferences in other java class then it ll shows errors.
in that case u need to pass the context or activity object.

this is the sample code

public class SharedPrefEx {

public void saveData(Context context, String value) {
SharedPreferences prefs = 
context.getSharedPreferences("MyPrefs",
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("One", value);
editor.commit();
}
}

u can call this method by creating object in our activity class i.e.
SharedPrefEx  sharedPrefs = new SharedPrefs();
sharedPrefs.saveData("Seshu");


On Mar 11, 9:03 am, Deepa M  wrote:
> SharedPreferences myPrefs =
> youractivityname.this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
>   SharedPreferences.Editor prefsEditor = myPrefs.edit();
>
>
>
>
>
>
>
>
>
> On Sun, Mar 10, 2013 at 12:15 AM, Jonathan S  wrote:
> > in Shared1, Context.MODE_PRIVATE
> > in Shared2, 
> > getContext().getSharedPreferences("top5",
> > Context.MODE_PRIVATE)
>
> > On Saturday, March 9, 2013 4:43:08 AM UTC-5, lselwd wrote:
>
> >> I have problem working with SHARED PREFERENCES, I think is project
> >> specific... i used the same before without errors but now get error see
> >> attachments, well?
>
> >  --
> > --
> > 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
> > ---
> > 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.
> > For more options, visithttps://groups.google.com/groups/opt_out.
>
> --
> Thanks& Regards
> Deepa M

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-10 Thread Deepa M
SharedPreferences myPrefs =
youractivityname.this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
  SharedPreferences.Editor prefsEditor = myPrefs.edit();



On Sun, Mar 10, 2013 at 12:15 AM, Jonathan S  wrote:

> in Shared1, Context.MODE_PRIVATE
> in Shared2, 
> getContext().getSharedPreferences("top5",
> Context.MODE_PRIVATE)
>
> On Saturday, March 9, 2013 4:43:08 AM UTC-5, lselwd wrote:
>>
>> I have problem working with SHARED PREFERENCES, I think is project
>> specific... i used the same before without errors but now get error see
>> attachments, well?
>>
>  --
> --
> 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
> ---
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Thanks& Regards
Deepa M

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-09 Thread Jonathan S
in Shared1, Context.MODE_PRIVATE
in Shared2, 
getContext().getSharedPreferences("top5",
 
Context.MODE_PRIVATE)

On Saturday, March 9, 2013 4:43:08 AM UTC-5, lselwd wrote:
>
> I have problem working with SHARED PREFERENCES, I think is project 
> specific... i used the same before without errors but now get error see 
> attachments, well? 
>

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-09 Thread lselwd
In a Canvas game if we have a class like:
*public class CannonView extends SurfaceView *
*   implements SurfaceHolder.Callback*
*{*
how transfer from this a var value to this
*public class CannonGame extends Activity*
*{*
without using static vars?

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: I have problem working with SHARED PREFERENCES, I think is project specific... i used the same before without errors but now get error

2013-03-09 Thread lselwd
public class CannonView extends SurfaceView 
   implements SurfaceHolder.Callback
{


this is its class , of function 

On Saturday, March 9, 2013 11:43:08 AM UTC+2, lselwd wrote:
>
> I have problem working with SHARED PREFERENCES, I think is project 
> specific... i used the same before without errors but now get error see 
> attachments, well? 
>

-- 
-- 
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
--- 
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.
For more options, visit https://groups.google.com/groups/opt_out.