db = this.getWritableDatabase();
ContentValues Val = new ContentValues();
Val.put("AccountID", "1");
Val.put("AccountName","Other");
db.insert(TABLE_MEMBER, null, Val);
db.close();
return new MatrixCursor(new String[] {"_id"});
โค๊ดการ SELECT เต็ม ครับ Code (Android-Java)
public Cursor SelectAllDataSpinner(){
SQLiteDatabase db;
db = this.getReadableDatabase();
String StrSQL = "SELECT AccountID AS _id , * FROM " + TABLE_MEMBER;
Cursor cursor = db.rawQuery(StrSQL, null);
try{
if(cursor.moveToFirst() && cursor.getCount() >= 1){
do{
return cursor;
}while(cursor.moveToNext());
}
db = this.getWritableDatabase();
ContentValues Val = new ContentValues();
Val.put("AccountID", "1");
Val.put("AccountName","Other");
db.insert(TABLE_MEMBER, null, Val);
db.close();
return new MatrixCursor(new String[] {"_id"});
}catch(Exception e){
return null;
}
}