MySQLite是什么东西,你自己导入的?

解决方案 »

  1.   

    MySQLite 自己写的?
    那应该是MySQLite里面的问题,另外,把异常log也贴出来,mysql空指针?
      

  2.   


    public class MySQLite extends SQLiteOpenHelper{
    private static final String DB_NAME = "test.db";
    private static final String TABLE_NAME ="user";
    private static final int DB_VERSION = 1;
    //应该是一个结构体中的元素;用于sql命令的书写
    private static final String ID = "id";
    private static final String NAME = "name";
    private static final String GENDER = "gender";
    private static final String TELEPHONE = "telphone";

    private static final String CREATE_DB_SQL = "CREATE TABLE" + TABLE_NAME +
    "("+ID + "integer primary key autoincrement,"+NAME +"text not null,"+GENDER 
    +"text,"+ TELEPHONE +"integer" +")";
     private static final String UPGRADE_SQL = "ALTER TABLE " + TABLE_NAME  
                + " ADD COLUMN " + " money float ";  
    //sql的构造函数;
    public MySQLite(Context context,String name,CursorFactory factory,int version){
    super(context,DB_NAME,null,version);
    }
    public void onCreate(SQLiteDatabase db){
    db.execSQL(CREATE_DB_SQL);//磁盘上没有时,要创建一个;对象也许已有,但磁盘上还没显示
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.execSQL(UPGRADE_SQL);
    }

    }回复1,2,3,4楼~~这是我对SQLiteOpenHelper()方法的实现~~~希望各位不吝指教
      

  3.   


    private static final String CREATE_DB_SQL = "CREATE TABLE" + TABLE_NAME +
                "("+ID + "integer primary key autoincrement,"+NAME +"text not null,"+GENDER 
                +"text,"+ TELEPHONE +"integer" +")";
    缺少必要的空格?
      

  4.   


    private static final String CREATE_DB_SQL = "CREATE TABLE " + TABLE_NAME +
                " ("+ID + " integer primary key autoincrement,"+NAME +" text not null,"+GENDER 
                +" text,"+ TELEPHONE +" integer" +")";
      

  5.   

    回复8# 加了空格之后还是没有看到,debug时还是创建数据库的时候失败,我想问下这和root权限有关吗?
      

  6.   

    把调用MySQLite 这个类的代码贴上来,感觉是你调用出错了.
      

  7.   

    还有 debug下 getApplicationContext() 这个是不是为空