1

如何使用 json 解析器将数据从我的 android 应用程序插入到我的数据库中,请帮助我提供一些类似的示例代码,我有这些代码,其中包含某些字段,如“电子邮件”、“密码”,我想将这些数据发送到特定网址

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class RegisterActivity extends Activity {

    EditText fullname;
    EditText email;
    EditText password;
    EditText RePass;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Set View to register.xml
        setContentView(R.layout.register);
        Button registerscreen=(Button)findViewById(R.id.btnCntnueRegister);
        // Listening to Login Screen link

        email = (EditText)findViewById(R.id.reg_email);
        password =(EditText)findViewById(R.id.reg_password);
        fullname =(EditText)findViewById(R.id.reg_fullname);
        RePass = (EditText)findViewById(R.id.rereg_password);
        EditText passwords=(EditText)findViewById(R.id.reg_password);
        passwords.setTransformationMethod(new PasswordTransformationMethod());
        EditText repasswords = (EditText) findViewById(R.id.rereg_password);
        repasswords.setTransformationMethod(new PasswordTransformationMethod());


        registerscreen.setOnClickListener(new View.OnClickListener(){

            public void onClick(View arg0) {
                Context context = getApplicationContext();
                int duration = Toast.LENGTH_SHORT;
                if(email.getText().toString().equals("")&&password.getText().toString().equals("")&&fullname.getText().toString().equals("")&&RePass.getText().toString().equals(""))
                {                                        
                    Toast toast = Toast.makeText(context, "Please Enter a valed data. !", duration);       
                    toast.show();
                }
                else if(email.getText().toString().equals("")||password.getText().toString().equals("")||fullname.getText().toString().equals("")||RePass.getText().toString().equals(""))
                {
                    Toast toast = Toast.makeText(context, "Please check any field is blank. !", duration);       
                    toast.show();
                }
                else if(password.getText().toString().compareTo(RePass.getText().toString())==0)
                {
                    Intent k = new Intent(getApplicationContext(), ContinueRegister.class);
                startActivity(k);
                }
                else
                {
                    Toast toast = Toast.makeText(context, "Password matching is failed. !", duration);       
            toast.show();


                }
            }
            });
      TextView loginScreen = (TextView) findViewById(R.id.link_to_login);

      loginScreen.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent m = new Intent(getApplicationContext(),LoginActivity.class);
            startActivity(m);

        }
    });
    }
}
4

0 回答 0