android ormlite登录注册的例子(8)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-25 11:34 点击:次
Map<String, Object> userMap=new HashMap<String, Object>();
userMap.put("username", username);
userMap.put("password", password);
List<UsersEntity> userlistEntities=userDao.queryForFieldValues(userMap);
return userlistEntities==null?null:userlistEntities;
}
public List<UsersEntity> findUser(Dao<UsersEntity, Integer> userdao,String username) throws SQLException
{
Dao<UsersEntity, Integer> userDao = userdao;
Map<String, Object> userMap=new HashMap<String, Object>();
userMap.put("username", username);
List<UsersEntity> userlistEntities=userDao.queryForFieldValues(userMap);
return userlistEntities==null?null:userlistEntities;
}
public void addsuer(Dao<UsersEntity, Integer> userdao,String username,String password) throws SQLException
{
Dao<UsersEntity, Integer> userDao = userdao;
UsersEntity usersEntity=new UsersEntity();
usersEntity.setUsername(username);
usersEntity.setPassword(password);
userDao.create(usersEntity);
}
}
最后是数据库管理类
Java代码
package com.cng.utils;
import java.sql.SQLException;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.cng.model.UsersEntity;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;
public class DataHelper extends OrmLiteSqliteOpenHelper
{
private static final String DATABASE_NAME = "OrmliteLoginDemo.db";
private static final int DATABASE_VERSION = 1;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>