试试这个:
public List<String> reTurn() throws SQLException
{
List<String> emails = new ArrayList<String>();
Cursor mCursor = db.rawQuery("SELECT EmailNO FROM Details_Customer ", null);
int index = mCursor.getColumnIndex(DBAdapter.COLUMN_EMAIL);
while(mCursor.moveToNext()) {
emails.add(mCursor.getString(index));
//password = mCursor.getString(11);
}
return emails;
}
从评论中添加
由此:
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ dbUser.reTurned});
我猜您正试图将电子邮件地址数组放入名为email
. 这是一个更好的方法:
public String[] reTurn() throws SQLException
{
Cursor mCursor = db.rawQuery("SELECT EmailNO FROM Details_Customer ", null);
String[] emails = new String[mCursor.getCount()];
int i = 0;
int index = mCursor.getColumnIndex(DBAdapter.COLUMN_EMAIL);
while(mCursor.moveToNext()) {
emails[i++] = mCursor.getString(index);
//password = mCursor.getString(11);
}
return emails;
}
并将其放入 Intent 中:
email.putExtra(Intent.EXTRA_EMAIL, dbUser.reTurned());
最后,在您的新活动中读取电子邮件数组:
String[] emails = getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL);
希望有帮助。