DODOcase for iPad 2 as good as the original

My love affair with the DODOcase is well documented. I’ve used one since day one, and I even credit one with saving my iPad’s life (though the manufacturers note that the DODOcase is not an impact case). So, I was thrilled to be able to test a DODOcase for iPad 2 for the last week. As a bonus, I’ve also been using a BOOKback for iPad 2. Both are quite nice and will be especially appealing to those who appreciate good design. Here’s my review.

Looks

The DODOcase has been re-designed to accommodate Apple’s new tablet, but the high-quality build and materials are unchanged. The exterior is wrapped in that nice, Moleskine-esque material and closes with a similar elastic band. The grain is a bit different than that on the notebooks, but at first glance, that’s what most people will assume you’re carrying.

On the inside, the iPad rests inside a hand-carved bamboo frame. Four rubber bumpers hold the iPad 2 firmly in place. And I mean firmly. I had to press to get it in where it was held tight. It’s a grip that inspires confidence; you know the typical bumps and nudges won’t knock your iPad free.

The top and bottom of the frame are cut away to expose the controls, speaker and dock connector (yes, you can connect the cable while the DODOcase is in use).

Continue reading DODOcase for iPad 2 as good as the original

DODOcase for iPad 2 as good as the original originally appeared on TUAW on Thu, 14 Apr 2011 09:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

TUAW’s Daily App: World of Goo

Let’s be honest here, … you probably already know all about World of Goo. You know it’s an excellent little physics puzzler from 2D Boy, and honestly, you probably already bought it, considering that it sold better on the iPad than any other platform and has even been seen in the Humble Indie Bundle. Even if you haven’t purchased it, you have probably heard from friends how inventive it is, and how building wacky towers of goo with little blobs to try and get them out of levels and into pipes is fun, funny and well worth the experience.

But there’s one thing you may not have heard about World of Goo, and that’s that it’s now out and available on the iPhone. For US$0.99, you can now play this terrific, highly recommended (currently the best-rated iOS game on Metacritic) title on Apple’s handheld smartphone. We probably don’t even need to sell you on it — you know if you want to go get it or not.

One word of warning, though: 2D Boy has also kindly updated the iPad version to work universally, so if you’ve already bought it on the iPad, you don’t need to buy it again in order to play it on your iPhone. Hopefully that info will get out there and save some people from buying it on a second device. Or a third, or a fourth, or however many times they’ve bought this much-loved game before.

TUAW’s Daily App: World of Goo originally appeared on TUAW on Thu, 14 Apr 2011 08:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Navigon adds augmented reality and enhanced traffic to iOS apps

You can add augmented reality to the feature list for the Navigon app. The company calls it Reality Scanner, and it shows destinations and nearby points of interest by superimposing that information over a live camera view. This is a feature best used by pedestrians; I’d hate to see someone driving and waving his iPhone around to use this.

Navigon is also adding what it calls Safety Camera alerts, which is a way to warn drivers of speed and red light cameras along the route. The information comes from the RoadTraps data base. The app works with US speed and red light cameras and is available as an in-app purchase of US$4.99 for a lifetime subscription. Navigon is also adding Traffic Check, which provides a quick graphic that appears after you plan a route, detailing traffic jams ahead of you. There is no charge for this service, and it does not require the paid Traffic Live feature to work.

MobileNavigator North America apps are on sale for $15 off until April 28. That would bring the USA version to $34.99. Traffic Live is on sale for $14.99 for a lifetime subscription. The Navigon app works on the iPhone, iPad and iPod touch. Check the gallery for some screen shots of the new features.

Navigon adds augmented reality and enhanced traffic to iOS apps originally appeared on TUAW on Thu, 14 Apr 2011 07:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Mactracker app hits version 6.0

Mactracker has been a TUAW favorite for a while. For those of you not familiar with it, it’s an application that lets you search a database of every Apple product ever made, including notebooks, iPods and even printers. Selecting an item shows you everything you could possibly want to know about it, whether it’s the original memory it shipped with, the maximum OS it can take, or even the model’s original cost in any number of currencies.

The version 6.0 release includes the latest Apple hardware, a new user interface and in-window search. As you can imagine, if you’re just curious about your Mac, Mactracker can answer most questions you have about its specs, but if you’re an IT specialist, Mactracker is an invaluable tool. Mactracker 6.0 is a free download from the developer’s website or on the Mac App Store.

Mactracker app hits version 6.0 originally appeared on TUAW on Thu, 14 Apr 2011 05:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Do-not-track feature coming to Safari

The latest developer release of Mac OS X 10.7 Lion includes a Safari web browser with do-not-track features built in. Do-not-track features in a web browser allow that browser to send messages to websites and advertising networks informing them that the user wishes not to be tracked. However, the feature is only effective if the advertiser or website agrees to not track a specific user, and right now advertisers and web sites are not legally required to honor the wishes of users using do-not-track features in browsers. As to be expected, major online advertising networks are dragging their heels saying they haven’t yet agreed on how to implement do-not-track systems effectively.

With the do-not-track feature built into Safari in Lion, Apple joins the ranks of Microsoft’s Internet Explorer and Mozilla’s Firefox as do-not-track browsers. Google’s Chrome is the only major do-not-track holdout. That should come as a shock to no one, considering Google is in the ad business. However, if you do use Chrome, you can download the free do-not-track extension Keep My Opt-Outs.

Do-not-track feature coming to Safari originally appeared on TUAW on Thu, 14 Apr 2011 01:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Tweetbot for iPhone / iPod touch: TUAW’s first look

Back when the iPhone platform was still young and the App Store had just opened its virtual doors, one of the most remarkable apps in what seemed to be an endless stream of poorly executed ideas was a gem called Weightbot. The app is still around, and the ‘bot still occupies a place of honor on my iPhone as it monitors the ups and downs of my diet.

Weightbot was the first in a series of apps from Tapbots, a development firm headlined by Mark Jardine and Paul Haddad. Each one of the succeeding apps, including Convertbot, Calcbot and Pastebot, has brought something innovative and well-designed to the market. While there were already a lot of unit conversion apps on the market by the time Convertbot hit the scene, Tapbots added an amazing interface with a rotating unit selector and conversion on the fly. Like Weightbot, the app is one of the few that still remains from the early days of the App Store.

So what could the Tapbots team bring their design savvy to next? We found out a few months ago when they announced Tweetbot (US$1.99 introductory price, $2.99 later). Now for many of us, the thought of yet another Twitter client was enough to cause extreme nausea. However, knowing the Tapbots folks, we were willing to take a closer look at this new app to see how it stands against the flock of Twitter apps already in the App Store. Take a gander at our first look at Tweetbot starting on the next page.

Gallery: Tapbots Tweetbot

Add accountTimelineThe tweet buttonsThat multi-function buttonNotification of new tweets

Continue reading Tweetbot for iPhone / iPod touch: TUAW’s first look

Tweetbot for iPhone / iPod touch: TUAW’s first look originally appeared on TUAW on Wed, 13 Apr 2011 23:05:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Jailbreak iPod Touch 3G / 4G iOS 4.3.2 with RedSn0w 0.9.6rc12 [How-to Guide]

These are the detailed steps to jailbreak iPod Touch 3G, 4G on iOS 4.3.2 tethered using RedSn0w 0.9.6rc12. RedSn0w 0.9.6 can jailbreak iOS 4.3.2 on iPod Touch 4G, iPod Touch 3G, iPhone 4, 3GS and iPad 1. Step-by-step jailbreak instructions after the jump…

Disclaimer: This guide is for educational and information purposes only. Follow the steps below at your own risk. We cannot be held responsible if anything goes wrong.

Let’s jailbreak iPod Touch 3G and iPod Touch 4G iOS 4.3.2 firmware with RedSn0w 0.9.6 RC.

Jailbreak iPod Touch 4G, 3G 4.3.2 tethered with RedSn0w 0.9.6rc

Step 1

Download the required stuff:

Step 2

Restore iOS 4.3.2 on your iPod Touch 4G/iPod Touch 3G and keep it connected to your computer via USB.
*You can skip this step if you’re already running iOS 4.3.2

Step 3

Rest of the steps are exactly similar to the guide posted earlier. Follow the guide linked below and continue from Step 3:

How to: Jailbreak iOS 4.3.2 with RedSn0w 0.9.6

You can follow us on Twitter, Join us at Facebook, and also Subscribed to RSS Feed to receive latest updates.

Digg Twitter StumbleUpon Facebook Reddit del.icio.us

Jailbreak iPhone 3GS / 4 4.3.2 iOS with RedSn0w 0.9.6rc12 [How-to Guide]

These are the steps to jailbreak iPhone 4, iPhone 3GS on 4.3.2 iOS tethered using RedSn0w 0.9.6rc12. RedSn0w 0.9.6 can jailbreak iOS 4.3.2 / 4.3.1 on iPhone 4, 3GS, iPod Touch 4G, 3G and iPad. Step-by-step jailbreak instructions after the jump…

Important

  • If you depend on UltraSn0w unlock, STAY AWAY from iOS 4.3.2 and RedSn0w.
  • UltraSn0w unlockers, wait for the PwnageTool/Sn0wbreeze update
  • Your iPhone 4, iPhone 3GS must be running iOS 4.3.2 in order to use RedSn0w jailbreak.

Disclaimer: This guide is for educational and information purposes only. Follow the steps below at your own risk. We cannot be held responsible if anything goes wrong.

Let’s tether jailbreak iPhone 3GS and iPhone 4 iOS 4.3.2 with RedSn0w 0.9.6rc12.

How to Jailbreak iPhone 3GS, 4 iOS 4.3.2 tethered with RedSn0w 0.9.6rc

Step 1

Download the required stuff:

Step 2

Restore iOS 4.3.2 on your iPhone 4/iPhone 3GS and keep it connect to your computer via USB.
*You can skip this step if you’re already running iOS 4.3.2

Step 3

Execute the Redsn0w 0.9.6 rc12

jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (9)

Step 4

Hit the Browse button and select official iOS 4.3.1 firmware (downloaded in Step 1), Yes, 4.3.1 NOT 4.3.2. RedSn0w will recognize your IPSW file. Then hit Next.

jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (8)jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (7)

Step 5

Now check mark “Install Cydia” and hit Next.
jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (6)jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (5)

Step 6

Now make sure your iPhone 4, iPhone 3GS is turned OFF and Plugged in to your computer. Hit Next.

jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (4)

Step 7

Now you’ll be instructed to put your iDevice into DFU Mode. Follow the on screen instructions.

jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (3)jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (2)jailbreak iphone 3gs 4 4.3.2 ios redsn0w 0.9.6rc12 (1)

Once you’ve successfully entered into DFU mode, RedSn0w will start jailbreaking iPhone 4 or iPhone 3GS on iOS 4.3.2 tethered. When done! your iPhone 4, iPhone 3GS will be jailbroken tethered on iOS 4.3.2.

Tether boot iPhone/iPod Touch/iPad

Since it’s a tether jailbreak, in order to boot your device you’ll need to tethered boot it with RedSn0w.

  1. Simply open RedSn0w 0.9.6rc12, browse and select iOS 4.3.1, hit next, and select “Just Tether Boot Right Now” and hit next.
  2. You’ll be instructed to put iDevice into DFU Mode.
  3. This should boot the device.

You can follow us on Twitter, Join us at Facebook, and also Subscribed to RSS Feed to receive latest updates.

Digg Twitter StumbleUpon Facebook Reddit del.icio.us

Download iOS 4.3.2 for iPhone 4, 3GS, iPad 2, iPad and iPod Touch 4G, 3G [IPSW]

iOS 4.3.2 firmware is now available for download. You can download iOS 4.3.2 for iPhone 4/3GS, iPad 2, iPad, and iPod touch 4G/3G. This minor firmware updates fixes bugs, FaceTime issues, various security loopholes and battery related issues for the iPhone, iPad and iPod Touch.

How to Install iOS 4.3.1

*** iOS 4.3.2 requires iTunes 10.2.1

To install iOS 4.3.2 on your device, connect your iPhone/iPod Touch/iPad to iTunes 10.2.1, new firmware availability message will appear then hit the “Download and Install” button. (Not recommended for jailbreakers and unlockers)

You can also download iOS 4.3.2 firmware from the links below. Hold down the Shit (Windows) or Alt/Option (Mac) key and hit the restore button on iTunes and select the downloaded IPSW file.

Download iOS 4.3.2 Firmware

You can download iOS 4.3.2 firmware (IPSW files) for iPhone 4, iPhone 3GS, iPad 2, 1 and iPod Touch 4G and 3G from the links below.

Download iOS 4.3.2 For IPhone 4

Download IOS 4.3.2 For IPhone 3GS

Download IOS 4.3.2 For IPod Touch 4G

Download IOS 4.3.2 For IPod Touch 3G

Download IOS 4.3.2 For IPad 2

Download IOS 4.3.2 For IPad

iTunes 10.2.1

You can download the latest iTunes 10.2.1 from the link below:

iOS 4.3.1 was released on March 25th. We’ll keep you updated as soon as iOS 4.3.2 jailbreak tools are available for download along with detailed step by step instructions.

Digg Twitter StumbleUpon Facebook Reddit del.icio.us

No iPhone 5 at WWDC. That’s good news.

@BenHarvell is a freelance writer and former editor of iCreate magazine. He writes for a wide range of international technology magazines and websites including Macworld, MacFormat and MacLife. He’s on Twitter and blogs at www.benharvell.com and is currently enjoying the latest social network, Tout.

It now seems clear that we wont be seeing an iPhone 5 at WWDC or any time before it. Great, let’s keep the focus on developing software not launching devices.

Whether the iPhone 5 has been hit by the predicted component delays or Apple is waiting to get rid of white iPhone 4 units before announcing a brand new product, having a completely focussed conference that wont raise questions on whether XYZ app will work with XYZ iPhone 5 feature should be a good thing.

It always struck me as strange that Apple announced new devices at WWDC. Sure, it has a nice captive audience that paid for the privilege of being there but for a conference about learning, sharing and receiving feedback, the fanfare of a new iPhone distracts from that.

It’s also good news for consumers and developers. If we’re not expecting the iPhone 5 until perhaps as late as September, it could mean that some significant new features are coming, requiring a longer lead time for developers to get apps ready.

This year looks set to be focussed solely on Mac OS and iOS and, if what I’ve seen of Lion remains the same until GM, there’ll be a lot of convergence talk between developers on either side of the mobile/desktop divide. It wouldn’t surprise me if launches were kept away from WWDC from now on.

If the above turns out to be true, it’s good to see Apple putting the developers first, be it a conscious decision or a forced hand. More face time (in real terms, not video conferencing!) with the guys that make the platform what it is and less grandstanding for the masses. That’s what WWDC should be all about.

 

Android App Development: Using SQLite database

Android default Database engine is Lite. SQLite is a lightweight transactional database engine that occupies small amout of disk storage and memory, so its a perfect choice for creating databases on many mobile operating systems such as Android, iOS.

Things to consider when dealing with SQLite:

  1. Data type integrity is not maintained in SQLite, you can put a value of a certain data type in a column of another dataype (put string in an integer and vice versa).
  2. Referential integrity is not maintained in SQLite, there is no FOREIGN KEY constraints or JOIN statements.
  3. SQLite Full Unicode support is optional and not installed by default.

In this tutorial we will create a simple database application to store employees data.

The DB has:
Tables:

  1. Employees
  2. Dept.

Views:

  1. ViewEmps: to display employees and their relative departments.

Creating SQLite Database

Default SQLite on Android does not have a management interface or an application to create and manage data bases from, so we’re going to create the database ourselves by code.

First we will create a class that handles all the operations required to deal with the database such as creating the database, creating tables, inserting and deleting records and so on.

The first step is to create a class that inherits from SQLiteOpenHelper class. this class provides two methods to override to deal with the database:

  1. onCreate(SQLiteDatabase db): invoked when the database is created, this is where we can create tables and columns to them, create views or triggers.
  2. onUpgrade(SQLiteDatabse db, int oldVersion, int newVersion): invoked when we make a modification to the database such as altering, dropping , creating new tables.

Our class will have the following members

public class DatabaseHelper extends SQLiteOpenHelper {

 static final String dbName="demoDB";
 static final String employeeTable="Employees";
 static final String colID="EmployeeID";
 static final String colName="EmployeeName";
 static final String colAge="Age";
 static final String colDept="Dept";

 static final String deptTable="Dept";
 static final String colDeptID="DeptID";
 static final String colDeptName="DeptName";

 static final String viewEmps="ViewEmps";

The Constructor:

public DatabaseHelper(Context context) {
  super(context, dbName, null,33);
  }

The constructor of the super class has the following parameters:

Context con: the context attached to the database.
dataBaseName: the name of the database.
CursorFactory: some times we may use a class that extends the Cursor class to implement some extra validations or operations on the queries run on the database. In this case we pass an instance of CusrsorFactory to return a reference to our derived class to be used instead of the default cursor,
In this example we are going to use the standard Cursor Interface to retrieve results, so the CursorFactory parameter is going to be null.

Version: the version of the schema of the database.

The constructor creates a new blank database with the specified name and version.

Creating the database:

The first superclass method to override is onCreate(SQLiteDatabase db):

public void onCreate(SQLiteDatabase db) {
  // TODO Auto-generated method stub

  db.execSQL("CREATE TABLE "+deptTable+" ("+colDeptID+ " INTEGER PRIMARY KEY , "+
    colDeptName+ " TEXT)");

  db.execSQL("CREATE TABLE "+employeeTable+" ("+colID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+
    colName+" TEXT, "+colAge+" Integer, "+colDept+" INTEGER NOT NULL ,FOREIGN KEY ("+colDept+")
REFERENCES "+deptTable+" ("+colDeptID+"));");

  db.execSQL("CREATE TRIGGER fk_empdept_deptid " +
    " BEFORE INSERT "+
    " ON "+employeeTable+

    " FOR EACH ROW BEGIN"+
    " SELECT CASE WHEN ((SELECT "+colDeptID+" FROM "+deptTable+" WHERE "+colDeptID+"=new."+colDept+" ) IS NULL)"+
    " THEN RAISE (ABORT,'Foreign Key Violation') END;"+
    "  END;");

  db.execSQL("CREATE VIEW "+viewEmps+
    " AS SELECT "+employeeTable+"."+colID+" AS _id,"+
    " "+employeeTable+"."+colName+","+
    " "+employeeTable+"."+colAge+","+
    " "+deptTable+"."+colDeptName+""+
    " FROM "+employeeTable+" JOIN "+deptTable+
    " ON "+employeeTable+"."+colDept+" ="+deptTable+"."+colDeptID
    );
  //Inserts pre-defined departments
  InsertDepts(db);

 }

The method creates tables with columns,a view and a trigger.

The method is invoked when the database is created. So we create our table and specify the columns.

This method is invoked when the database does not exist on the disk, it’s executed only once on the same device at the first time the application is run on the device.

Upgrading the database:

some times we want to upgrade the database by changing the schema, add new tables or change column data types.
this is done by overriding onUpdate(SQLiteDatabase db,int old Version,int newVerison) method:

Public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  // TODO Auto-generated method stub

  db.execSQL("DROP TABLE IF EXISTS "+employeeTable);
  db.execSQL("DROP TABLE IF EXISTS "+deptTable);

  db.execSQL("DROP TRIGGER IF EXISTS dept_id_trigger");
  db.execSQL("DROP TRIGGER IF EXISTS dept_id_trigger22");
  db.execSQL("DROP TRIGGER IF EXISTS fk_empdept_deptid");
  db.execSQL("DROP VIEW IF EXISTS "+viewEmps);
  onCreate(db);
 }

This method is invoked when the version number specified in the constructor of the class changes.

When you want to append a change to your database you must change the version number in the constructor of the class:

So when you pass the constructor a version number of 2:

public DatabaseHelper(Context context) {
  super(context, dbName, null,2);

  // TODO Auto-generated constructor stub
 }

Instead of 1:

super(context, dbName, null,2);

The application understands that you want to upgrade the database and onUpgrade method will be invoked

A typical implementation of this method is to drop the tables and create them again with the additional modifications.

Managing Foreign-Key Constraints:

We will create a trigger that ensures that when a new Employee is inserted his/her Dept value is present in the original Dept table.

The sql statement to create such a trigger would be like this:

CREATE TRIGGER fk_empdept_deptid Before INSERT ON Employees
FOR EACH ROW BEGIN
    SELECT CASE WHEN ((SELECT DeptID FROM Dept WHERE DeptID =new.Dept ) IS NULL)
    THEN RAISE (ABORT,'Foreign Key Violation') END;
    END

In onCreate method we created this trigger like this:

db.execSQL("CREATE TRIGGER fk_empdept_deptid " +
    " BEFORE INSERT "+
    " ON "+employeeTable+

    " FOR EACH ROW BEGIN"+
    " SELECT CASE WHEN ((SELECT "+colDeptID+" FROM "+deptTable+" WHERE "+colDeptID+"=new."+colDept+" ) IS NULL)"+
    " THEN RAISE (ABORT,'Foreign Key Violation') END;"+
    "  END;");

Executing SQL statements:

Now let’s begin executing basic sql statements. you can execute any sql statement that is not a query whether it is insert, delete, update or anything using db.execSQL(String statement) method like when we did when creating the database tables:

db.execSQL("CREATE TABLE "+deptTable+" ("+colDeptID+ " INTEGER PRIMARY KEY , "+
    colDeptName+ " TEXT)");

Inserting records:

We insert records to the databse using the following code for example to insert records in the Dept table:

SQLiteDatabase db=this.getWritableDatabase();
 ContentValues cv=new ContentValues();
   cv.put(colDeptID, 1);
   cv.put(colDeptName, "Sales");
   db.insert(deptTable, colDeptID, cv);

   cv.put(colDeptID, 2);
   cv.put(colDeptName, "IT");
   db.insert(deptTable, colDeptID, cv);
                     db.close();

Notice that we need to call this.getWritableDatabase() to open the connection with the database for reading/writing.
the ContentValues.put has two parameters: Column Name and the value to be inserted.

Also it is a good practice to close the database after executing statements.

Updating values:

To execute an update statement we have two ways

  1. to execute db.execSQL
  2. to execute db.update method:
public int UpdateEmp(Employee emp)
  {
   SQLiteDatabase db=this.getWritableDatabase();
   ContentValues cv=new ContentValues();
   cv.put(colName, emp.getName());
   cv.put(colAge, emp.getAge());
   cv.put(colDept, emp.getDept());
   return db.update(employeeTable, cv, colID+"=?", new String []{String.valueOf(emp.getID())});

  }

The update method has the following parameters:

  1. String Table: the table to update a value in
  2. ContentValues cv: the content values object that has the new values
  3. String where clause: the WHERE clause to specify which record to update.
  4. String[] args: the arguments of the WHERE clause.

Deleteing rows:

As in update to execute a delete statement we have two ways

  1. to execute db.execSQL
  2. to execute db.delete method:
public void DeleteEmp(Employee emp)
  {
   SQLiteDatabase db=this.getWritableDatabase();
   db.delete(employeeTable,colID+"=?", new String [] {String.valueOf(emp.getID())});
   db.close();
  }

The delete method has the same parameters as the update method.

Executing queries:

To execute queries there are two methods:

  1. Execute db.rawQuery method.
  2. Execute db.query method.

To execute a raw query to retreive all departments

Cursor getAllDepts()
  {
   SQLiteDatabase db=this.getReadableDatabase();
   Cursor cur=db.rawQuery("SELECT "+colDeptID+" as _id, "+colDeptName+" from "+deptTable,new String [] {});

   return cur;
  }

The rawQuery method has two parameters:

  1. String query: the select statement.
  2. String[] selection args: the arguments if a WHERE clause is included in the select statement.

Notes:

  1. The result of a query is returned in Cursor object.
  2. In a select statement if the primary key column (the id column) of the table has a name other than _id then you have to use an alias in the form SELECT [Column Name] as _id
  3. cause the Cursor object always expects that the primary key column has the name _id or it will throw an exception .

Another way to perform a query is to use a db.query method.

A query to select all employees in a certain department from a view would be like this:

public Cursor getEmpByDept(String Dept)
  {
   SQLiteDatabase db=this.getReadableDatabase();
   String [] columns=new String[]{"_id",colName,colAge,colDeptName};
   Cursor c=db.query(viewEmps, columns, colDeptName+"=?", new String[]{Dept}, null, null, null);
   return c;
  }

The db.query has the folowing parameters:

  1. String Table Name: the name of the table to run the query against.
  2. String [ ] columns: the projection of the query i.e the columns to retrieve.
  3. String WHERE clause: where clause, if none pass null.
  4. String [ ] selection args: the parameters of the WHERE clause.
  5. String Group by: a string specifying group by clause.
  6. String Having: a string specifying HAVING clause.
  7. String Order By by: a string Order By by clause.

Managing Cursors:

Result sets of queries are returned in Cursor objects.
There are some common methdos that you will use with cursors:

  1. boolean moveToNext(): moves the cursor by one record in the result set, returns false if moved past the last row in the result set.
  2. boolean moveToFirst(): moves the cursor to the first row in the result set, returns false if the result set is empty.
  3. boolean moveToPosition(int position): moves the cursor to a certain row index within the boolean result set, returns false if the position is un-reachable
  4. boolean moveToPrevious():moves the cursor to the preevious row in the result set, returns false if the cursor is past the first row.
  5. boolean moveToLast():moves the cursor to the lase row in the result set, returns false if the result set is empty.

There are also some useful methods to check the position of a cursor:
boolean isAfterLast(), isBeforeFirst, isFirst,isLast and isNull(columnIndex).

Also if you have a result set of only one row and you need to retreive values of certain columns, you can do it like this:

public int GetDeptID(String Dept)
  {
   SQLiteDatabase db=this.getReadableDatabase();
   Cursor c=db.query(deptTable, new String[]{colDeptID+" as _id",colDeptName},colDeptName+"=?",
new String[]{Dept}, null, null, null);
   //Cursor c=db.rawQuery("SELECT "+colDeptID+" as _id FROM "+deptTable+" WHERE "+colDeptName+"=?",
new String []{Dept});
   c.moveToFirst();
   return c.getInt(c.getColumnIndex("_id"));

  }

We have Cursor.getColumnIndex(String ColumnName) to get the index of a column.

Then to get the value of a certain column we have Cursor.getInt(int ColumnIndex) method.
Also there are getShort,getString,getDouble, getBlob to return the value as a byte array.

It’s a good practice to close() the cursor after using it.

That’s was all about using SQLite in Android, stay tuned for another tutorial next week.

Understanding button press events

This is the “ButtonPress” example. I am going to show you the simplest way to press the button and change the event of button pressed.

Step 1: Open the Xcode and create a new Xcode project using View base application template. Give the application name “ButtonPress”. As shown in the figure below:

Step 2: Expand classes and notice Interface Builder created the ButtonPViewController.h and ButtonPViewController.m class for you. Expand Resources and notice the template generated a separate nib, ButtonPViewController.xib file.

Step 3: Open the ButtonPViewController.h file and add IBOutlet UILabel *statusText;
For displaying the Label Text, mention two IBAction. To perform the given actions make the following changes in the file.

#import <UIKit/UIKit.h>

@interface ButtonPViewController : UIViewController {
        IBOutlet UILabel *statusText;

}
@property (retain,nonatomic) UILabel *statusText;

(IBAction)buttonpressed:(id)sender;
(IBAction)buttonpressed1:(id)sender;
@end

Step 4: Double click the ButtonPAppViewController.xib file and after that make the following changes.
A) Open the view window, first drag the Round Rect Button from the library and place it to the view window and select the button.

B) Open the view window, and drag the Label from the library and place it to the view window.

Step 5: Open the ButtonPViewController.m file and make the following changes in the file.

#import "ButtonPViewController.h"

@implementation ButtonPViewController
@synthesize statusText;

(IBAction)buttonpressed:(id)sender
{
        NSString *newText =[[NSString alloc]initWithFormat:@"Right button pressed"];
        statusText.text=newText;
        [newText release];
}
(IBAction)buttonpressed1:(id)sender
{
        NSString *newText =[[NSString alloc]initWithFormat:@"Left button pressed"];
        statusText.text=newText;
        [newText release];
}

Step 6: Now build and run the code and view the Output in the Simulator.

You can download source code from here ButtonPress

Sudden spike in iTunes ‘The item you tried to buy is no longer available’ errors

We have no idea why (sorry!), but there’s apparently a surge in “missing” apps in the App Store tonight. This results in the error message “The item you tried to buy is no longer available” when you attempt to purchase.

Based on our search traffic hitting this post, the problem started earlier this evening and is affecting at least the US, UK, Canadian and Australian app stores. Apple’s Pages is reportedly one of the affected apps.

Chances are this is a transient glitch and will be sorted out soon, so the best advice for the moment is to be patient and try again in an hour or so. If it’s not cleared up by the AM hours on the East Coast we’ll update this post.

Sudden spike in iTunes ‘The item you tried to buy is no longer available’ errors originally appeared on TUAW on Wed, 13 Apr 2011 22:40:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Bloomberg: White iPhone 4 to arrive by the end of April

For those of you waiting for the white iPhone 4 ever since Apple announced it almost ten months ago, your wait may soon be coming to an end. Bloomberg is citing “three people familiar with the plans” who say the white iPhone 4 will begin shipping in the next few weeks. The white iPhone will be available from both AT&T and Verizon.

The white iPhone was delayed a number of times because Apple was reportedly not happy with the quality of the paint. Apple even went so far as to go back to the drawing board and partnered with a Japanese manufacturer to create a new type of paint that allowed for greater control of the thickness of it when applied to a material.

Bloomberg’s sources echo what Apple’s senior vice president of worldwide product marketing Phil Schiller said earlier this year — that the white iPhone 4 was still coming and it would be released sometime in the spring. Upon launch, it is assumed that the white iPhone 4 will ship in 16 GB and 32 GB versions like the black iPhone 4.

Bloomberg: White iPhone 4 to arrive by the end of April originally appeared on TUAW on Wed, 13 Apr 2011 22:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments