没有这样的表:android中的FTSdictionary_content(table_name)

时间:2013-12-07 11:20:03

标签: android sqlite android-sqlite

我有一个sdcard数据库。我想从SD卡读取数据。

为此,我做了以下编码

    DbHelper helper = new DbHelper(this);
    SQLiteDatabase database = helper.getWritableDatabase();
    //in below line I am getting no such table error
    Cursor c = database.query(TestDataSource.TABLE_NAME, null, null, null, null, null, null);
    c.moveToFirst();
    do{
        System.out.println(c.getString(1));
    }while(c.moveToNext());

在DbHelper课程中,我也完成了以下代码:

    public class DbHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "gujarati.db";
private static final int DATABASE_VERSION = 1;
SQLiteDatabase mDatabase;

public DbHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase database) {
    System.out.println("On Create is called");
    String dir = Environment.getExternalStorageDirectory().getPath();
    File dbfile = new File(dir + File.separator + "gujarati.db");
    System.out.println("is file exits " + dbfile.isFile());
    mDatabase = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
    Cursor ti = mDatabase.rawQuery(
            "PRAGMA table_info(FTSdictionary_content)", null);
    if (ti.moveToFirst()) {
        do {
            System.out.println("col: " + ti.getString(1));
        } while (ti.moveToNext());
    }
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

onCreate工作正常。此外,我得到“FTSdictionary_content”表的所有列名称,但在游标启动时我收到错误。

0 个答案:

没有答案