English 中文(简体)
甲状腺炎( j)
原标题:android: java.lang.illegalargumentexception column details does not exists

我看到,有人问:是。 但是,我的问题是数据库中定义的其他一栏会产生疑问。

public class DatabaseHelper extends SQLiteOpenHelper{

    static final String dbName="Shadows";
    static final String pages="pages";
    static final String pages_id="_id";
    static final String date="date";
    static final String details="details";

    public DatabaseHelper(Context context) {
        super(context, dbName, null, 33);
    }

    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS pages (_id INTEGER PRIMARY KEY AUTOINCREMENT, date TEXT, details TEXT);");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+pages);
        onCreate(db);
    } 


    public Cursor getallPages(){
        SQLiteDatabase db=this.getReadableDatabase();
        Cursor c=db.rawQuery("SELECT * FROM PAGES", new String[] {});
        return c;
    }
}

现在,在打电话到这个<代码>植被()功能之后,使用简单的 cur调器。

String[] from = new String[]{
    DatabaseHelper.pages_id,
    DatabaseHelper.date,
    DatabaseHelper.details
};
int[] to = new int[]{R.id.id,R.id.name,R.id.mail};
SimpleCursorAdapter sca = new SimpleCursorAdapter(
    this,R.layout.gridview,c,from,to
);

它给出了一个错误“没有细列细节”。 预 收

最佳回答

Two things.

你们应当使用Lucor的最终静态现场细节,这将避免任何细微的打字。

db.execSQL("CREATE TABLE IF NOT EXISTS "+pages+" ("+pages_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "+date+" TEXT, "+details+" TEXT);");

选择

 Cursor c=db.rawQuery("SELECT * FROM "+pages, new String[] {});

这种做法有好的做法,也意味着如果你决定改变某种做法,那么它就会自动得到关注。

但是,最可能的原因是,数据库(和表格)已经存在,但形式不同——如果你最近修改了该守则,以添加或重新命名详细栏,那么该法典就会 t倒,重新计算表格。

简单测试——仅从该装置中清除该仪器的数据,然后又再次使用该仪器——像你这样认为,正在增加数据库版本,以便做同样的事情,你肯定你这样做吗?

Other than a faulty pre-existing database this looks like it should work.

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签