device.js
function readMessageInChunksFromOutbox(message_hash, len, handleMessage){
	var CHUNK_LEN = 1000000;
	var start = 1;
	var message = '';
	function readChunk(){
		db.query("SELECT SUBSTR(message, ?, ?) AS chunk FROM outbox WHERE message_hash=?", [start, CHUNK_LEN, message_hash], function(rows){
			if (rows.length === 0)
				return handleMessage();
			if (rows.length > 1)
				throw Error(rows.length+' msgs by hash in outbox, start='+start+', length='+len);
			message += rows[0].chunk;
			start += CHUNK_LEN;
			(start > len) ? handleMessage(message) : readChunk();
		});
	}
	readChunk();
}
function readMessageInChunksFromOutbox(message_hash, len, handleMessage){
	var CHUNK_LEN = 1000000;
	var start = 1;
	var message = '';
	function readChunk(){
		db.query("SELECT SUBSTR(message, ?, ?) AS chunk FROM outbox WHERE message_hash=?", [start, CHUNK_LEN, message_hash], function(rows){
			if (rows.length === 0)
				return handleMessage();
			if (rows.length > 1)
				throw Error(rows.length+' msgs by hash in outbox, start='+start+', length='+len);
			message += rows[0].chunk;
			start += CHUNK_LEN;
			(start > len) ? handleMessage(message) : readChunk();
		});
	}
	readChunk();
}
function readMessageInChunksFromOutbox ( message_hash , len , handleMessage ) { var CHUNK_LEN = 1000000 ; var start = 1 ; var message = '' ; function readChunk ( ) { db . query ( "SELECT SUBSTR(message, ?, ?) AS chunk FROM outbox WHERE message_hash=?" , [ start , CHUNK_LEN , message_hash ] , function ( rows ) { if ( rows . length === 0 ) return handleMessage ( ) ; if ( rows . length > 1 ) throw Error ( rows . length + ' msgs by hash in outbox, start=' + start + ', length=' + len ) ; message += rows [ 0 ] . chunk ; start += CHUNK_LEN ; ( start > len ) ? handleMessage ( message ) : readChunk ( ) ; } ) ; } readChunk ( ) ; }
a hack to read large text from cordova sqlite
a hack to read large text from cordova sqlite