SQLiteDatabase db = this.getReadableDatabase();
Cursor mCursor =db.query(TABLE_ACCOUNTS, new String[]{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s}, null,null, null, null, null);
我的问题是:这个初始化是否允许返回 db 数据库和表中的所有值?
就我的项目而言,它似乎只返回 NULL 值。(无错误)a = null,b = null,c = null
当我用 a+"=?" 操作第三个参数时检测到一些实际值 和变体(现在为空)。
或者防止实际值是别的什么?(假设将数据添加到数据库有效)
(添加代码)
public void addAccount() {
SQLiteDatabase db = this.getWritableDatabase();
Account account = new Account();
ContentValues values = new ContentValues();
values.put(id, account.getA()); // Contact Name
values.put(a, account.getA()); // Contact Phone Number
values.put(b, account.getB()); // Contact Phone Number
values.put(c, account.getC());
...
db.insert(TABLE_ACCOUNTS, null, values);
db.close(); // Closing database connection
}
(光标代码)
if ( (mCursor != null && mCursor.moveToFirst()) ) {
do {
stringResult1 =
"a: "+ mCursor.getString(0)+ "\n"
+ "b: " + mCursor.getString(1) + "\n"
+ "c: " + mCursor.getString(2) + "\n"
+ "d: " + mCursor.getString(3) + "\n"
+ "e: " + mCursor.getString(4) + "\n"
+ "f: " + mCursor.getString(5) + "\n"
+ "g: " + mCursor.getString(6) + "\n"
+ "h: " + mCursor.getString(7) + "\n"
+ "i " + mCursor.getString(8) + "\n"
+ "j: " + mCursor.getString(9) + "\n"
+ "k: " + mCursor.getString(10) + "\n"
+ "l: " + mCursor.getString(11) + "\n"
+ "m: " + mCursor.getString(12) + "\n"
+ "n: " + mCursor.getString(13) + "\n"
+ "o: " + mCursor.getString(14) + "\n"
+ "p: " + mCursor.getString(15) + "\n"
+ "q: " + mCursor.getString(16) + "\n"
+ "r: " + mCursor.getString(17) + "\n"
+ "s: " + mCursor.getString(18) + "\n";
} while (mCursor.moveToNext());
// make sure to close the cursor
mCursor.close();
}