Codeboxed

code out of the box

Follow me on TwitterRSS FeedsRecommend me on Facebook

  • Home
  • Titanium Mobile
  • Titanium Desktop
  • Titanium API Browser
  • Titanium Tips
  • About

Create a database with Titanium Mobile

Aug 18th

Posted by codeboxed in Titanium

2 comments

Many of the mobile projects we worked on required working with a database. In Titanium you can either use an existing database which is useful in some cases, or create a database from within the application.

Here are some guidelines on how to create and use a database:

Open/Create a database

    var myDatabase = Ti.Database.open('myDatabase');

Titanium.Database.open opens the database passed as a parameter or creates a new one if the one specified does not exist.

Create a table

If the database is opened for the first time (created), you need to create a table.

var sql = 'CREATE TABLE IF NOT EXISTS my_table(' +
    'id INTEGER PRIMARY KEY AUTOINCREMENT, my_column TEXT, my_column2  INT' +
')';

myDatabase.execute(sql);

Titanium.Database.DB.execute executes a SQL statement against the database. The function receives two parameters. The first one is the SQL string that will be executed and the second parameter can be one or more parameters to replace ? or an array of objects to be replaced in the SQL string using ? substitution.

Insert data

 var sql = 'INSERT INTO my_table (my_column, my_column2) VALUES (?,?)';

myDatabase.execute(sql, 'My string', 4);

Update data

    var sql = "UPDATE my_table SET my_column = ? WHERE id = ?";

    myDatabase.execute(sql, 'New value', 1);

Retrieve data

    var sql = 'SELECT * FROM my_table WHERE id = ?';

    myDatabase.execute(sql, 1);

Delete data

    var sql = 'DELETE FROM my_table WHERE id = ?';

    myDatabase.execute(sql, 1);

Delete a table

    myDatabase.execute('DROP TABLE IF EXISTS logs');

If you have any questions or comments, please feel free to use the comments section of this post or send them to us on Twitter or Facebook.

create, database, db, delete, execute, insert, open, select, sqlite, table, titanium mobile, update

Titanium Module for Android Audio Recording

Aug 4th

Posted by codeboxed in Titanium

27 comments

We were watching over the Appcelerator Q&A page and saw that a lot of people are requesting a way to record audio without using Intents. Don’t get me wrong, the post published by Bill Dawson (Launching Activities and Using Content URIs in Android), was awesome and it really helped a lot, but we all needed a way to do this without using an interface that wasn’t customizable, so audioRecorder came into the equation.

I hope that this will be helpful and i would really love that all you guys out there, using it, comeback with proposal of new modules or updates and ideas to the current ones.

Fell free to contact us at: team[at]codeboxed[dot]com, and we will respond as soon as possible, i am sure there are a lot of people that can vouch for our rapid response time ;) , so don’t worry, we take all of the e-mail and messages very serious.

So lets talk a little about this new Titanium module called audioRecorder (com.codeboxed.audiorecorder).

The audioRecorder module has 14 methods that we thought would be of great use. I really recommend that if you don’t know what the audio encoders or audio formats represent on Android, go check this out: MediaRecorder Android Class, and learn more about it, but i am sure the documentation included with the module will be very easy to understand and make the use of the module very straight forward.

Some of the important features of the module are the following methods: setMaxDuration, setMaxFileSize, setRandomFileName, start, stop, playAudio

Here is some short info about some of them, info that you will also find in the documentation of the audioRecorder Titanium module:

More >

android, play audio, record audio, titanium, titanium api, titanium mobile, titanium module

Titanium Module for Box.net REST API

Aug 2nd

Posted by codeboxed in Javascript

1 comment

Box.net has a collection of web services which allows developers to connect to their platform and store/retrieve/manipulate/share files and folders. Their API is fairly simple to use from any programming language, and they have wrappers for most of the popular languages like PHP, Java, .NET, Ruby, etc. You can access their API through REST, SOAP and XML-RPC protocols.

We decided to try out the Box platform and develop a simple application in Titanium. The process itself was easy though time-consuming, as you have to write lots of code to use the API functions. Therefore, we wrote an API wrapper over the RESTful web service in order to cut-down on the development time. This is useful for any developer who wants to develop Titanium Mobile applications integrated with the Box platform.

Example application

In order to fully demonstrate the module’s integration with the Box API and show how easy-to-use, we implemented an example application. Download the example application from here or fork it from GitHub.

Titanium Box.net Example Application 1
Titanium Box.net Example Application 2
Titanium Box.net Example Application 3


How to use

The Titanum Module has four methods which allows to call any of the API functions described on the official Box API Documentation.

Prerequisites

You need to be registered with a Box account, and create an application in order to obtain your own API key. This process is straight-forward and shouldn’t take you more than 5 minutes. Once you have your account set-up, go to the Box platform services site and create a new application.

Include the Titanium Module
    var box = require('com.codeboxed.boxrestapi');
Use the module

.load(callback [Function - optional], options [Array - optional])

The first method which needs to be called in order to initialize the module. It is recommended to provide at least a callback function as a parameter. More >

api, box rest api, box.net, iphone, module, RESTful, titanium api, titanium module, web service

How to install a Titanium Module

Aug 1st

Posted by codeboxed in Android

15 comments

Modules are a great way to add functionality to your applications, in addition to what the Titanium Mobile API provides. You can install modules that extend the UI, perform a specific task that cannot done otherwise or just combine Titanium API modules and objects in order to provide a high-level functionality.

There are two steps that you need to take in order to install a Titanium module:

Copy the module

  1. Go to /Library/Application Support/Titanium or to ~/Library/Application Support/Titanium
  2. Unarchive the .zip file and you will get a “modules” folder
  3. Copy the “modules” folder into one of the paths mentioned in step 1

Register the module

Register the module with your application by editing tiapp.xml and adding your module:


    {MODULE_ID}

Example (for Titanium Image Gallery 0.2 for iPhone):


    com.codeboxed.imagegallery

Use the module

var moduleReference = Ti.require('com.example.module');

Note: You might need to do a full rebuild in order for the module to be included properly.

how, how to, how to install, image gallery, install, modules, titanium mobile, titanium module, tutorial

Titanium Image Gallery module for iPad

Jul 18th

Posted by codeboxed in Titanium

1 comment

The 0.2 version of the Titanium Image Gallery module for iOS is ready to download. In this new version we optimized the image gallery for iPad and added new options to further customize the module.

Here is a snippet of code on how to customize the module:

// Import ImageGallery module
var ImageGallery = require('com.codeboxed.imagegallery');

var win = Ti.UI.currentWindow;

// Array with image objects
var imagesArray = [
    {path:'1.jpg', caption:'Kitten 1'},
    {path:'2.jpg', caption:'Kitten 2'}
];

// Initialize the Image Gallery
var imageGallery = ImageGallery.create({
    images: imagesArray,
    columns: 4, // Set the numbers of column (optional). Default is 4
    thumbSize: 75, // Set the thumb image size (optional). Default is 75
    thumbPadding: 5 // Set the thumb image padding (optional). Default is 5
});

// Add it to the current window
win.add(imageGallery);

We created a screencast showing the Image Gallery in action on the iPad simulator: More >

image gallery, iOS, ipad, titanium image gallery, titanium module

Titanium Module for Image Gallery

Jul 7th

Posted by codeboxed in Javascript

3 comments

We implemented a Titanium Module for using an image gallery in your mobile application. The code is based on the initial Image Gallery script.

The current module supports only one parameter (the local images array), but we are working on allowing it to be fully customizable and support remote images.

Here’s an example on how to use the module:

// Import ImageGallery module
var ImageGallery = require('com.codeboxed.imagegallery');

var win = Ti.UI.currentWindow;

// Array with image objects
var imagesArray = [
    {path:'1.jpg', caption:'Kitten 1'},
    {path:'2.jpg', caption:'Kitten 2'}
];

// Initialize the Image Gallery
var imageGallery = ImageGallery.create({
    images: imagesArray
});

// Add it to the current window
win.add(imageGallery);

The module is pure Javascript and currently available only for iPhone, and soon for Android.

For installing instructions check the Github repository.

image, image gallery, iphone, javascript, module, pictures, titanium, titanium api, titanium mobile

How to implement “More” Tab on Android

Jul 1st

Posted by codeboxed in Android

10 comments

The vast majority of iPhone applications have a tab named “More” which holds the rest of the tabs which are not displayed in the tab bar. This design is done by default by the application when there are more tabs that the tab bar could display.

Android, on the other hand, crowds all the tabs together and scrolls the tab title if necessary. Although some may prefer this design, we like the way iPhone handles it.

We decided to simulate this design on Android, which is in particular useful if you have to implement the same application on both platforms.

Check the code snippet: More >

android, iphone, more, simulate, tab, TabGroup, titanium mobile

We’ve released Titanium API Browser

Jun 9th

Posted by codeboxed in Titanium

No comments

We recently released our own application for browsing the Titanium Mobile API. There are some other apps out there that solved this problem already, but we have ours free of cost, available on the main mobile/desktop platforms and promise to release an update within days Appcelerator releases a new API version.

The application is available for Mac, Windows and Android at the moment but we are working on releasing it for iPhone and Linux also.

If you want to give it a go, check out the application’s page.

android, download, iphone, mac, titanium api, titanium api browser, windows

Connect with Titanium Mobile to your databases

Jun 6th

Posted by codeboxed in Titanium

3 comments

Initially we created a Gist for connecting with Titanium to your databases which is for the Titanium Desktop API.

We modified the previous Gist to work with the Titanium Mobile API following some guidelines from the Google Javascript Style Guide.

To see the whole article click here: More >

database, gist, javascript, sqlite, titanium api, titanium mobile

How to install an iPhone Ad-Hoc Distribution

May 31st

Posted by codeboxed in Tutorials

No comments

What is an Ad-Hoc Distribution?

An iPhone Ad-Hoc distribution is used to test the application before submitting it to the Apple Store.

Requirements

You will need the following things before installing the distribution profile:

  • The .ipa file for the application,
  • The .mobileprovision file for the application,
  • A device on which you want to install the application. Your device UDID has to be included in the .mobileprovision file,
  • A computer for which the device has been sycronized before (or else set-up the device before following the steps below).

More >

ad hoc, app, device, distribution, how, how to, how to install, iphone, iTunes, mobile, profile, provisioning
123»
  • Search the box

  • Facebook

  • Latest tweets

    Loading tweets...
    Follow me on Twitter!
  • Titanium API Browser

    Unofficial API reference documentation for the Appcelerator Titanium™ Mobile platform.

    Updated for 1.7.0 mobile API.

    • Download for Android
    • Download for iPhone
    • Download for Mac OS X
    • Download for Windows
    • Download for Linux
  • Codeboxed on Github

    codeboxed does not have any public repositories.Follow codeboxed on GitHub
  • Tag Cloud

    about android api app asynchronous check file copy file create file database desktop download exists flash getFile help how how to how to install image gallery iphone javascript mac os x main menu mobile module mp4 nib properties python quicktime script snippet sqlite titanium Titanium.App.Properties titanium api titanium desktop titanium filesystem titanium menu titanium mobile titanium module titanium network tutorial video windows
    • RSS GitHub Activity

      • codeboxed created repository crayon-cms February 27, 2013
      • codeboxed starred appcelerator/titanium_mobile April 17, 2012
      • codeboxed starred senchalabs/jsduck April 17, 2012
      • codeboxed closed issue codeboxed/Titanium-Image-Gallery#11 February 16, 2012
      • codeboxed closed issue codeboxed/Titanium-Image-Gallery#8 February 16, 2012
    • Recent Posts

      • Create a database with Titanium Mobile
      • Titanium Module for Android Audio Recording
      • Titanium Module for Box.net REST API
      • How to install a Titanium Module
      • Titanium Image Gallery module for iPad
    • Recent Comments

      • Titanium Devil on Install the NEW Android SDK on Titanium Mobile
      • Xyclos on Show YouTube videos with Titanium mobile
      • Saurabh Saxena on Titanium Desktop vs. Titanium Mobile
      • Paulo Andre Filipak on Titanium Module for Android Audio Recording
      • Paulo Andre Filipak on Titanium Module for Android Audio Recording
Copyright © 2013 Codeboxed Top