示例#1
0
 /** 数据初始化 */
 private void initData() {
   SqliteControl sqliteControl = new SqliteControl(UserInfo.this);
   SQLiteDatabase db = sqliteControl.getDatabase();
   String sqlString = "select name,sex,address,registertime,marry,hobby,email from user";
   Cursor cursor = db.rawQuery(sqlString, null);
   if (cursor.getCount() == 0) {
     // 用户尚未登录,跳转到登录界面
     cursor.close();
     sqliteControl.close();
     Intent intent = new Intent();
     intent.setClass(UserInfo.this, UserLogin.class);
     intent.putExtra("from", "UserInfo");
     startActivity(intent);
     finish();
   } else {
     cursor.moveToFirst();
     user_info_name.setText(cursor.getString(0));
     user_info_sex.setText(cursor.getString(1));
     user_info_address.setText(cursor.getString(2));
     user_info_registertime.setText(cursor.getString(3));
     user_info_marry.setText(cursor.getString(4));
     user_info_hobby.setText(cursor.getString(5));
     user_info_email.setText(cursor.getString(6));
   }
 }
示例#2
0
 public void onClick(View v) {
   SqliteControl sqliteControl = new SqliteControl(UserInfo.this);
   SQLiteDatabase db = sqliteControl.getDatabase();
   db.delete("user", null, null);
   sqliteControl.close();
   Intent intent = new Intent();
   intent.setClass(UserInfo.this, UserLogin.class);
   intent.putExtra("from", "UserInfo");
   startActivity(intent);
   finish();
 }