通过向网址添加编辑文本值来访问网站数据库

时间:2013-10-20 19:44:54

标签: java android eclipse

我希望访问我的网站数据库并通过编辑文本和onClick添加用户。我完成了大部分应用程序。从PC上执行此操作非常简单,因为我只是在URL中的适当位置添加用户编号,然后将它们添加到数据库中。

这是添加了用户的URl

http://something.com/user/426561?token=dYG8hW5TY4LBU8jfPb10D3IcsSx8RTo6

我想使用编辑文本在426561处插入数字值。这就是我到目前为止,我的网站提出了一个无效的用户编号错误,应该这样做。

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);




    edttext= (EditText)findViewById(R.id.editText1);


    Button tutorial2 = (Button) findViewById(R.id.button1);
      tutorial2.setOnClickListener(new OnClickListener() {


        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.putExtra("edttext", edttext.getText().toString());
               intent.setData(Uri.parse("http://something.com/user/= edttext?token=dYG8hW5TY4LBU8jfPb10D3IcsSx8RTo6"));
              startActivity(intent);    

        }

      });

我已添加到网址,但显然我没有正确地执行此操作。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

使用它。添加额外内容不会取代意图中的数据

intent.setData(Uri.parse("http://example.com/user/"+edttext.getText() +"?token=dYG8hW5TY4LBU8jfPb10D3IcsSx8RTo6"));