android - Export data (offline): save and share a file -
i offer convenient way backup data cordova app users. appealing me app backup data json file , offer user save/share same way other file.
i've got far saving data real file , invoking share dialog, file fails share/save. it's because external apps don't have permissions access file created app (gmail says: 'permission denied attachement') , don't know how allow external apps access file created app. ideas?
my code:
ex = json.stringify(ex); window.resolvelocalfilesystemurl('cdvfile://localhost/temporary/', function(dir) { console.log('directory resolved.'); dir.getfile('makeshift.json', {create: true, exclusive: false}, function(file) { console.log('date file created.'); file.createwriter(function (filewriter) { filewriter.onwriteend = function() { console.log('data saved.'); var time = date.now(); console.log(file); // typeof fileentry window.plugins.socialsharing.sharewithoptions({ message: 'my makeshift backup '+time, subject: 'makeshift backup '+time.yyyymmdd(), files: [file.nativeurl], choosertitle: 'choose how save data' }, function(result) { file.remove(function (file) { console.log('data file removed.'); }); }); }; filewriter.onerror = function(e) { console.log('there error writing data file.', e); }; filewriter.write(new blob([ex], { type: 'application/json' })); }); }, function(err) { console.log('there error creating data file.', err); }); });
Comments
Post a Comment