是否可以将共享首选项中的数据插入到mysql数据库中?

时间:2016-01-27 07:44:14

标签: php android mysql insert sharedpreferences

是否可以将SharedPreferences内的数据插入远程MySQL数据库?假设我将为已登录的特定用户插入产品,或者您可能知道更好的方法。我正在使用SharedPreferences进行登录会话。

如果你知道关于它的教程,请分享,我需要在我的项目中,我是Android开发的新手。

1 个答案:

答案 0 :(得分:0)

是的,你可以。

首先:从SharedPreferences

中检索数据
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MyActivity.this);
Integer myValue = sp.getInt("myKey", 0);

然后:将返回的值插入数据库:

本教程介绍如何在MySQL数据库中执行INSERT:http://sampleprogramz.com/android/mysqldb.php

希望它有所帮助。

相关问题