Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get email addresses from Android E-Mail app
/* with kind regards to http://www.samuelbosch.com/2018/02/split-into-rows-sqlite.html */
WITH RECURSIVE split(predictorset_id, predictor_name, rest) AS (
SELECT _id, '', fromList || char(1) || toList || char(1) FROM Message WHERE _id
UNION ALL
SELECT predictorset_id,
substr(rest, 0, instr(rest, char(1))),
substr(rest, instr(rest, char(1))+1)
FROM split
WHERE rest <> '')
SELECT DISTINCT
CASE WHEN instr(predictor_name, char(2))
THEN substr(predictor_name, 0, instr(predictor_name, char(2)))
ELSE predictor_name END
as email,
substr(predictor_name, instr(predictor_name, char(2))+1) as name
FROM split
WHERE predictor_name <> ''
UNION
SELECT accountAddress as email,
accountName as name
FROM EmailAddressCache
ORDER BY email;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment