2011-06-11 133 views
1

令牌在从OAuth流中检索后应该保存在哪里?将它们保存在手机的本地数据库中更好吗,还是错过了更好的方法?Android OAUTH令牌存储

感谢您的意见。

回答

4

一个好方法是将它们保存到共享偏好对象,其中你找回他们时,你要发送的tweet等,像这样:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); 
final Editor edit = prefs.edit(); 
edit.putString(OAuth.OAUTH_TOKEN, consumer.getToken()); 
edit.putString(OAuth.OAUTH_TOKEN_SECRET,consumer.getTokenSecret()); 
edit.commit();