DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


sample_code:backup_apps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
sample_code:backup_apps [2015/11/13 18:40]
stevegarman [Backup your apps]
sample_code:backup_apps [2015/11/14 16:00] (current)
stevegarman upate code
Line 5: Line 5:
  
 If you wish, you can save the mail as a draft, rather than sending it. If you wish, you can save the mail as a draft, rather than sending it.
 +
 +Or instead of choosing a mail app to send the file, you may be able to choose an archiving app that is on your device, such as **Google Drive**.
  
 <code JavaScript archive.js>​ <code JavaScript archive.js>​
-//var mygmail = "​my.own.address@gmail.com";​ +var mygmail = app.GetUser()
-var mygmail ​= app.GetUser();​+var txt,​ yesNo,​ archname;
  
 //​Called when application is started. //​Called when application is started.
Line 14: Line 16:
 { {
     //​Create a layout with objects vertically centered.     //​Create a layout with objects vertically centered.
-    lay = app.CreateLayout( "​linear",​ "​FillXY"​ );​    +    var lay = app.CreateLayout( "​linear",​ "​FillXY"​ );​    
  
  
Line 37: Line 39:
     var zip = app.CreateZipUtil();​     var zip = app.CreateZipUtil();​
     var fldr = "/​sdcard/​DroidScript";​     var fldr = "/​sdcard/​DroidScript";​
-    var archname = (new Date).toISOString().slice(0,​19 );​+    archname = (new Date).toISOString().slice(0,​19 );​
     archname = "​ds"​+archname.replace(/​[-:​]/​g,""​);​     archname = "​ds"​+archname.replace(/​[-:​]/​g,""​);​
     archname =  archname.replace(/​T/,"​_"​);​     archname =  archname.replace(/​T/,"​_"​);​
-    var file = archfolder+archname+"​.zip";+    archname += "​.zip";​ 
 +    var file = archfolder+archname
 +    archname = app.GetModel()+"/"+archname;
     zip.Create( file );​     zip.Create( file );​
  
Line 72: Line 76:
     {     {
         var fname = yesNo.fname;​         var fname = yesNo.fname;​
-        app.SendMail( mygmail,​ fname,​ "​DroidScript backup attached",​ fname );​+        app.SendMail( mygmail,​ archname,​ "​DroidScript backup attached",​ fname );​
     }     }
 } }
- 
 </​code>​ </​code>​
 ===== Warnings ===== ===== Warnings =====
-==== Personalise the code ==== 
-You must change the email address in the first line 
 ==== Version required ==== ==== Version required ====
 This code makes the assumption that you are using at least version 1.15 of DroidScript,​ as the path for your apps is hard coded but older versions used a different path This code makes the assumption that you are using at least version 1.15 of DroidScript,​ as the path for your apps is hard coded but older versions used a different path
sample_code/backup_apps.txt · Last modified: 2015/11/14 16:00 by stevegarman