如何使用DatabaseHelper类将用户详细信息发送到mysql数据库

时间:2012-09-25 18:49:52

标签: android mysql

尝试使用databasehelper.java将使用facebook详细信息登录到我的应用程序的用户详细信息发送到mysql数据库这里我在DatabaseHelper中收到错误helper1 = new DatabaseHelper(this);是否有任何语法错误或我用于将数据发送到我的服务器的错误代码?

public void getProfileInformation() {
     Bundle params = new Bundle();
        params.putString("fields", "id,name,email");

    mAsyncRunner.request("me", new RequestListener() {
        @Override
        public void onComplete(String response, Object state) {
            Log.d("Profile", response);
            String json = response;
            try {
                JSONObject profile = new JSONObject(json);
                // getting name of the user
                final String name = profile.getString("name");
                // getting email of the user
                final String email = profile.getString("email");
                final String id = profile.getString("id");

                /*runOnUiThread(new Runnable() {

                    @Override
                    public void run() {

                        Toast.makeText(getApplicationContext(),
                                "Name: " + name + "\nEmail: " + email + "\nid" + id,
                                Toast.LENGTH_LONG).show();
                    }

                });*/

                if(id != null && id.length() > 0){

                    String accessToken = null;
                    DatabaseHelper helper1 = new DatabaseHelper(this);
                    DatabaseUtility dao = new DatabaseUtility(helper);
                    try {
                        accessToken = dao.getAccessToken();
                    } catch (Exception e1) {
                    }
                    Map<String , String> params = new HashMap<String,String>();
                    params.put(Constants.FACEBOOK_ID, id);
                    params.put(Constants.ACCESS_TOKEN_PARAM, accessToken);
                    Status status = null;
                    try {
                        status = Utils.addFacebookAccount(params, LoginActivity.this);
                    } catch (NullPointerException e) {
                    } 
                    catch (JSONException e) {
                    }

                    Utils.showErrorMessage(getApplicationContext(), Constants.CONNECTED_TO_FACEBOOK_ERROR, Constants.TOAST_VISIBLE_LONG);

                    Intent i=new Intent(getApplicationContext(),ProfileActivity.class);
                    startActivity(i);
            }}
                catch (JSONException e) {
                e.printStackTrace();
            }
        }

0 个答案:

没有答案