Back

QueryContent

Hello World

Queries content from the android content model.

app.QueryContent( uri, columns, select, args, sort )

The uri typically have the syntax “content://authority/path/id”. You can find more infos about it on the Android Developer page.

The coloumns are specific for the database you are accessing. You can get this information from the respective content provider.

select is a optional sql command to filter the results.

args is an optional parameter for arguments you want to include to the sql command. The placeholder for these arguments are '?' signs in the sql command.

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.

Example - Show Contacts

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );
    lst = app.CreateList( "", 1, 1 );
    lay.AddChild( lst );
    app.AddLayout( lay );

    var uri = "content://com.android.contacts/data";
    var columns = "display_name,data1";
    var select = "mimetype='vnd.android.cursor.item/phone_v2'";
    var rows = app.QueryContent( uri, columns, select, null, "display_name" );

    var list = [];
    for(var i in rows)
        list.push( rows[i].display_name + ":" + rows[i].data1 + ": " );

    lst.SetList( list );
}
Copy All       Run      
list
string: comma “,” separated
string: sql code
string: url path
string: coloumn