Search code examples
javascripttizen-wearable-sdktizen-web-app

findSuccess method itemsList is always undefined


I am new to Tizen working on a small application I am not able to figure out what is the problem.

When I am using these lines before it was working fine but now

var audioOnly = new tizen.AttributeFilter('type', 'EXACTLY', 'AUDIO');
    tizen.content.find(findSuccess, findError, null, audioOnly);

Here is code for findSuccess which add lines in log

findSuccess(itemsList){
        console.log('total items:'+itemsList);
        console.log(itemsLis.name+'etc..');
 }

In findSuccess method itemsList is always undefined, no object fetched even when there are files in the device. All settings are proper permissions for read and write is set in config.xml file.

This is Tizen webapi code


Solution

  • I tried with below code.

    function findSuccess(items) {
            for ( var i in items) {
                console.log('Item title: ' + items[i].title);
                console.log('Item URI: ' + items[i].contentURI);
                console.log('Item type: ' + items[i].type);
           }
        }
    
        function onError(error) {
             console.log('Error: ' + error);
          }
    
    
     // Function to get list of all certain media files
        function getSelectedMediaList() {
           var mediasource = null;
           mediasource = tizen.content;
           var type = 'AUDIO';
           var filter = new tizen.AttributeFilter("type", "EXACTLY", type);
           try {
                 mediasource.find(findSuccess, onError, null, filter);
           } catch (exc) {
                console.log("findItems exception:" + exc.message);
           }
       }
    
        getSelectedMediaList();
    

    Don't forget to add privileges in config.xml

     <tizen:privilege name="http://tizen.org/privilege/content.write"/>
     <tizen:privilege name="http://tizen.org/privilege/content.read"/>