package com.chenqi.service;
import java.util.ArrayList;
import java.util.List;
import com.chenqi.domain.User;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
public class UserService {
private DBOpenHelper dbOpenHelper;
public UserService(Context context) {
this.dbOpenHelper = new DBOpenHelper(context);
}
/*public void payment(){
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
db.beginTransaction();//事启事务
try{
db.execSQL("update person set amount=amount-10 where personid=?", new Object[]{1});
db.execSQL("update person set amount=amount+10 where personid=?", new Object[]{2});
db.setTransactionSuccessful();//设置事务标志为成功,当结束事务时就会提交事务
}finally{
db.endTransaction();
}
}*/
public void save(User user){
//如果要对数据进行更改,就调用此方法得到用于操作数据库的实例,该方法以读和写方式打开数据库
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
db.execSQL("insert into userinfo (username,pwd,sex,age,telephone) values(?,?,?,?,?)",
new Object[]{user.getUsername(),user.getPwd(),user.getSex(),user.getAge(),user.getTelephone()});
}
public String findTedianByShengxiaoName(String name){
//如果只对数据进行读取,建议使用此方法
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select tedian from shengxiao where shengxiaoname=?", new String[]{name.trim()});
if(cursor.moveToFirst()){
String tedian = cursor.getString(cursor.getColumnIndex("tedian"));
return tedian;
}
return null;
}
public String findTedianByxingzuoName(String name){
//如果只对数据进行读取,建议使用此方法
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select tedian from xingzuo where xingzuoname=?", new String[]{name.trim()});
if(cursor.moveToFirst()){
String tedian = cursor.getString(cursor.getColumnIndex("tedian"));
return tedian;
}
return null;
}
public String findTedianByxuexingName(String name){
//如果只对数据进行读取,建议使用此方法
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select tedian from xuexing where xuexingname=?", new String[]{name.trim()});
if(cursor.moveToFirst()){
String tedian = cursor.getString(cursor.getColumnIndex("tedian"));
return tedian;
}
return null;
}
public String findTedianBytwoxingzuo(String nanxingzuo,String nvxingzuo){
//如果只对数据进行读取,建议使用此方法
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select tedian from peidui where nanxingzuo=? and nvxingzuo=?", new String[]{nanxingzuo.trim(),nvxingzuo.trim()});
if(cursor.moveToFirst()){
String tedian = cursor.getString(cursor.getColumnIndex("tedian"));
return tedian;
}
return null;
}
public void insertPeidui(){
//如果要对数据进行更改,就调用此方法得到用于操作数据库的实例,该方法以读和写方式打开数据库
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
/*db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","白羊座","躲在他的怀里,真的是天底下最温暖的一件事了.但守旧好静的他,的确跟不上你求新爱闹的脚步,留着他的电话号码吧!也许有一天你会再想起他.两情相悦指数:3"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","金牛座","这个专制的男人,对你而言简直像个暴君,在一次他坚持要你穿上最性感的衣服去赴宴时,你终于再也不愿忍受,这段恋情就此告终。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","双子座","在床上,他和你一样善于制造惊喜浪漫的气氛,但他的专制,和你不喜受拘束的个性,势必要起冲突。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","巨蟹座","他是个专制的暴君,喜爱热闹,你却性好恬静。本质既不相同,即使他显露出脆弱的一面,你也该义无反顾地离开他。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","狮子座","戏剧化而激情的恋爱过程,精彩程度绝不下于任何爱情文艺剧,你俩同样享受这种猛烈的爱,在床上亦然。但别轻易破坏和平,否则……"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","处女座","他让你陷入激情的热恋之中,但他那狂风暴雨的脾气令你震惊,更最受不了的还是他上厕所的习惯--关于马桶盖,你终于忍无可忍。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","天秤座","他是个外向活泼而有无穷精力的恋爱高手,你们的确有过澎湃的一段情,但他的专制,令你只想把他收藏在记忆中。两情相悦指数:5天长地久指数:3"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","天蝎座","你渴望细水长流的恋情,他却冲动躁进,你对他而言是难以承受之重,他对你而言,真的是难以承受之轻浮。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","射手座","他和你一样独立、爱自由,能纵情享乐而不担忧明日,只要不论及将来,你们可以一直相处愉快。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","魔羯座","虽然他很有野心,但他的实力的确赶不上你的帐单,想到后面还有许多医生、律师在排队,你实在没空多理他。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","水瓶座","精力充沛的他,对一切新奇的事物都能保持高度的兴趣,这点倒是与你不谋而合。但做完爱后,马上倒头呼呼大睡的作风,实在令人不敢恭维。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"白羊座","双鱼座","他的冲动、富攻击性,实在有悖于你慢工出细活的原则。在他第五次草草了事之后,你开始反省,这一切是否值得?当然答案是否定的。两情相悦指数:2天长地久指数:1"});*/
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","双鱼座","他总是记得帮你把冰箱填满食物,你真的是太感动了,你终于找到一个能完全照顾你的人。在床上,你们的步调亦相当一致。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","水瓶座","他是完全遵循惯性定律的动物,喜欢熟悉而固定的模式,你的做爱方式把他吓坏了。两情相悦指数:3天长地久指数:2"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","魔羯座","他沉稳的个性的确抓得住你情绪的波动。在床上,你们亦非常契合,他不在意为你煮饭打扫,只要偶尔你也爬爬梯子换灯泡即可。两情相悦指数:5天长地久指数:4"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","射手座","他善妒、固执,而且坚持事情有一定的规律。他精力无穷,甚至可以天天做爱,但是,一定要在床上。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","天蝎座","他稳重而持续的付出,令你感动。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","天秤座","在性爱方面,你们的确有很好的互动。但你们毕竟是分属两个不同世界的人,他希望生活有一定的规律,你却一日数变,如果你们可以彼此互相体谅,或许还犹有可为。两情相悦指数:4天长地久指数:3"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","处女座","只要顺着他的毛摸,妳就能完全掌握住他,他重视干净的厨房和床铺,这点与你不谋而合。天生一对,还有什么理由可挑剔呢?"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","狮子座","他是个占有欲强的吝啬鬼,而你则花钱似流水。虽然在床上你俩可真的配合得完美无瑕,但除此之外,别无共通点。"});
db.execSQL("insert into peidui (nanxingzuo,nvxingzuo,tedian) values(?,?,?)",
new Object[]{"金牛座","巨蟹座","他的慵懒和你的贤慧适成一对。谁在乎他饭后喜欢窝在电视前睡觉呢?反正,你也正想边看电视边享用�