Basics Of Titanium


1.Fromate Time in Titanium

title=”Download Latest or Old Version of Titanium sdk.” target=”_blank”>http://builds.appcelerator.com.s3.amazonaws.com/index.html#3_1_X

var foo = new Date();

var date = dateName[foo.getMonth()] + ” ” + foo.getDate()+ ” ” +foo.getFullYear() ;

var time=String.formatTime(foo);

2. Add days on Date in Titainum

foo.setDate(foo.getDate() +364)

3. Hide Nav Bar in Titanium

var win=Ti.UI.currentWindow;

win.hideNavBar();

4.Alert Dialog In Titanium

var alertDialog = Titanium.UI.createAlertDialog({

title:’Alerts Empty’,

message:’To begin please add your first alert with the plus button above.’,

buttonNames : [‘Ok’]

});

alertDialog.addEventListener(‘click’, function(e) {

switch(e.index) {

case 0:

break;

}

});

alertDialog.show();

5.Database Management In titanium

var databaseName = ‘Reefland’;

function createDataBase(){

var db = Titanium.Database.open(databaseName);

//db.file.setRemoteBackup(false);

db.execute(‘CREATE TABLE IF NOT EXISTS Aquarium (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT , size INTEGER, type TEXT,created_Time DATE, modified_Time DATE)’);

/*db.execute(‘CREATE TABLE IF NOT EXISTS Organizations(id INTEGER PRIMARY KEY,items_accepted Text,name Text,detail Text)’);

db.execute(‘CREATE TABLE IF NOT EXISTS DonationItems ‘+

‘(id INTEGER PRIMARY KEY,category Text,org_id INTEGER,items TEXT,date DATE,time TEXT,user_id TEXT)’);*/

Titanium.API.info(‘+++++++++++++++Tables check completed++++++++++’);

db.close();

}

function db_insertAquariumItems(name,size,type,time,alt_time)

{

var db = Titanium.Database.open(databaseName);

db.execute(‘INSERT INTO Aquarium(name,size,type,created_Time,modified_Time) VALUES(?,?,?,?,?)’,name,size,type,time,alt_time);

var rows = db.execute(‘SELECT * FROM Aquarium’);

Titanium.API.info(‘ROW COUNT = ‘ + rows.getRowCount());

rows.close();

db.close();

}

function db_fetchValuesFromDatabase(tablename)

{

var db = Titanium.Database.open(databaseName);

var rows = db.execute(‘SELECT * FROM ‘+tablename);

Titanium.API.info(‘ROW COUNT = ‘ + rows.getRowCount());

return rows;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: