从SQLite DB Android读取/写入

时间:2014-04-13 15:54:33

标签: android json database sqlite

(在DB类中)

 public PlayerDatabase(Context context) {
        super(context, DATABASE_PLAYER_MANAGER, null, DATABASE_VERSION);
    }

(在活动/片段中)

private SQLiteDatabase mPlayerDB;
myDB = new PlayerDatabase(mContext);

        mPlayerDB = myDB.getWritableDatabase();
        ContentValues cv = new ContentValues();
        cv.put(myDB.KEY_KEYS, response.getString("keys"));
        cv.put(myDB.KEY_DATA, response.getString("data"));
        cv.put(myDB.KEY_VERSION, response.getString("version"));
        mPlayerDB.insert(PlayerDatabase.TABLE_PLAYERS, null, cv);
        mPlayerDB.close();

响应是JSON不为null并且具有所有数据。它似乎把它放在数据库中,但当我去检索它时,

Cursor cursor = mPlayerDb.query(PlayerDatabase.TABLE_PLAYERS, PlayerDatabase.DATABASE_COLUMNS, null, null, null, null, null);

我得到“(1)没有这样的表:playersTable”

“插入数据时出错= {(json info)};

0 个答案:

没有答案