妈的 今天弄了一天 数据库创建失败 :想死的心情都有了 ,直到现在突然想到 是不是数据库的路径不对
妈的 原来真是数据库的路径不对
数据库的打开与创建:
try
{
SQLiteDatabase sld=SQLiteDatabase.openDatabase
(
"/data/data/com.huping.sql/mydb", //数据库所在路径 ******* 蓝色部分必须是应用程序的包名 前面路径也是死的
null, //CursorFactory
SQLiteDatabase.OPEN_READWRITE|SQLiteDatabase.CREATE_IF_NECESSARY //读写、若不存在则创建
);
//如果不存在表 则创建
String sql="create table if not exists student(sno char(5),stuname varchar(20),sage integer,sclass char(5))";
sld.execSQL(sql);
}
catch(Exception e)
{
Toast.makeText(this, "数据库错误:"+e.toString(), Toast.LENGTH_SHORT).show();
}