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
Next revision
Previous revision
sample_code:backup_apps [2015/01/11 23:36]
stevegarman change to use external mail app
sample_code:backup_apps [2015/11/15 00:00] (current)
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 txt, yesNo, archname;
  
 //Called when application is started. //Called when application is started.
Line 13: 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 36: 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(/[-:]/gi,""); +    archname = "ds"+archname.replace(/[-:]/g,""); 
-    archname =  archname.replace(/T/gi,"_"); +    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 71: 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.1421019397.txt.gz · Last modified: 2015/01/12 07:36 (external edit)