Thanks. However, the device I'm working on doesn't have an internet 
connection nor any accounts set up, so whenever I try to access the 
accounts, even just accounts[0], I get a ArrayIndexOutOfBoundsException.

On Monday, August 13, 2012 4:11:48 PM UTC+8, jb wrote:
>
> You can store key/value pairs in Accounts, via the Account 
> Manager. I never did it, but I guess it could fit your needs, 
> since you anyway seem to plug-in into some Account 
> validation, right? 
>
> http://developer.android.com/reference/android/accounts/AccountManager.html 
>
> See getUserData(), setUserData() 
>
> Sihan Goi schrieb: 
> > Hi, 
> > 
> > Is it possible to share data between the Android framework and an app? 
> > 
> > I'm modifying the Android framework login component so that a variable 
> > will be saved upon login, and then later retrieved by another app. I'm 
> > trying to use SharedPreferences, and my code looks like this: 
> > 
> > In com.android.internal.policy.impl.PasswordUnlockScreen.java, I have 
> > the following code to write to the SharedPreferences. 
> > 
> > SharedPreferences prefs = getContext().getSharedPreferences("mypref", 
> > Context.MODE_WORLD_READABLE); 
> > SharedPreferences.Editor editor = prefs.edit(); 
> > editor.putString("mypref", "my data" 
> > editor.commit(); 
> > 
> > In my other app, I have the following code to read from it. 
> > 
> > Context con; 
> > String data; 
> > try { 
> >    con = this.createPackageContext("com.android.internal.policy.impl", 
> 0); 
> >    SharedPreferences pref = con.getSharedPreferences("mypref", 
> > Context.MODE_PRIVATE); 
> >    data = pref.getString("mypref", "0") 
> > } catch (NameNotFoundException e) { 
> >    data = "0"; 
> >    Log.e("No data shared", e.toString()); 
> > } 
> > 
> > When I run the code, I keep getting the NameNotFoundException, as it 
> > claims the application package com.android.internal.policy.impl is not 
> > found, so my data is always "0". 
> > 
> > How can I share data between these 2 components? 
> > 
> > Thanks. 
> > 
> > -- 
> > - Goi Sihan 
> > goi...@gmail.com <javascript:> <mailto:goi...@gmail.com <javascript:>> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Android Developers" group. 
> > To post to this group, send email to 
> > android-d...@googlegroups.com<javascript:> 
> > To unsubscribe from this group, send email to 
> > android-developers+unsubscr...@googlegroups.com <javascript:> 
> > 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 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

Reply via email to