我有一个 sqlite 数据库,我想检索特定的数据列并将其存储到字符串数组中。数据库内部有两列。会有多行具有相同用户名的数据,我想检索用户的“ContentPath”并将其存储到字符串数组中。但我不知道如何检索该特定列数据...
public String[] get_contentByEmailID(String emailid){
String[] returnMsg = null;
helper = this.getReadableDatabase();
Cursor c = helper.rawQuery("SELECT tableid, emailid, contentpath" +
" from w_content where emailid='"+emailid"' ", null);
int contentpathColumn = c.getColumnIndex("contentpath");
if (c.moveToFirst()) {
do {
returnMsg = new String[2];
String contentpath = c.getString(contentpathColumn);
returnMsg[0] = emailid_sync;
returnMsg[1] = contentpath;
} while (c.moveToNext());
}
if (c != null && !c.isClosed()) {
c.close();
}
if (helper!=null){
helper.close();
};
return returnMsg;
}
当我调用这个函数来检索数据时。它提供了 emailid 和 contentpath。
String values[] = helper.get_contentByEmailID(SettingConstant.EMAIL);
任何意见将不胜感激。