明天考试题,大神求帮助
package com.example.jrkl;import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.jrkl.R;
public class ChangeActivity extends Activity{
EditText edPwd,edId,edAge,edName;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_change);
edPwd = (EditText) findViewById(R.id.ed_change_pwd);
edId = (EditText) findViewById(R.id.ed_change_userid);
edAge = (EditText) findViewById(R.id.ed_change_age);
edName = (EditText) findViewById(R.id.ed_change_name);
btn = (Button) findViewById(R.id.btnChange);
String sql = "SELECT * FROM user WHERE "+Constant.USERID+"=?";
Cursor cursor = new Tools(getBaseContext()).getDataBase().rawQuery(sql, new String[]{new Tools(getBaseContext()).getPreferenceHelper().getString((Constant.USERID))});
while(cursor.moveToNext()){
String pwd = cursor.getString(cursor.getColumnIndex(Constant.PWD));
String age = cursor.getString(cursor.getColumnIndex(Constant.AGE));
String name = cursor.getString(cursor.getColumnIndex(Constant.NAME));
String userid = cursor.getString(cursor.getColumnIndex(Constant.USERID));
edPwd.setText(pwd);
edId.setText(userid);
edAge.setText(age);
edName.setText(name);
}
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String id = edId.getText().toString();
String pwd = edPwd.getText().toString();
String age = edAge.getText().toString();
String name = edName.getText().toString();
if(id.equals("") || pwd.equals("") ||age.equals("") ||name.equals("")){
Toast.makeText(getApplicationContext(), "请输入完整信息", Toast.LENGTH_SHORT).show();
return;
}
ContentValues values = new ContentValues();
values.put(Constant.USERID, id);
values.put(Constant.NAME, name);
values.put(Constant.PWD, pwd);
values.put(Constant.AGE, age);
new Tools(getBaseContext()).getDataBase().update("user", values, Constant.USERID+"=?",
new String[]{new Tools(getBaseContext()).getPreferenceHelper().getString((Constant.USERID))});
new Tools(getBaseContext()).getPreferenceHelper().putString(Constant.USERID, id);
Toast.makeText(getApplicationContext(), "更新成功", Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
明天考试,老师给了这么一段程序,完全不懂。。。求大神告诉~写的什么意思