wesley tanaka

Tech

Drop, modify, change or rename a column from a SQLite table in Android

()

SQLite only supports a limited subset of ALTER TABLE, so to modify an existing column, it's necessary to create a separate table. The SQLite documentation recommends doing two separate INSERT/SELECT operations using a temporary table, instead of doing an INSERT/SELECT followed by an ALTER TABLE RENAME TO.

Running a SQLite database transaction in Android

()

The idiom for SQLite transactions in Android is:

db.beginTransaction();
try {
  // Do database operations here ...
  db.setTransactionSuccessful();
} finally {
  db.endTransaction();
}

Responsive AdSense Leaderboard ad unit for Twitter Bootstrap 2.3.2

()

Twitter Bootstrap 2.3.2 sets its media query responsive layout breaks at 768px, 980px, (and 1200px), which are suitable for including a Mobile Banner (320 x 50), Leaderboard (728 x 90), or a  Large Leaderboard (970 x 90). It's possible to do this with the new beta Responsive ad unit AdSense ad size.

java.lang.IllegalArgumentException: transactions on multiple entity groups only allowed in High Replication applications

()

If you run a Java Google App Engine unit test with a vanilla LocalDatastoreServiceTestConfig instance, you will run into the error java.lang.IllegalArgumentException: transactions on multiple entity groups only allowed in High Replication applications:

Keys-only query using JDO in Google App Engine Java

()

To turn a Java Google App Engine JDO query into a keys-only query, call setResult(String) on it to specify that only the @PrimaryKey column should be returned.  JDO will convert this into a keys-only query on the datastore.

For example, if your entity class looks like this:

public class YourEntity {
  @PrimaryKey
  private String name;
// ...

Call a JSP from a servlet

()

If you want to include/execute a .jsp file from within a servlet, you can use the forward() method of the request dispatcher.

Move Android SearchView Icon inside the text field

()

The Android SearchView, which allows you to display a search UI embedded inside the ActionBar at the top of your activity, can sometimes display a magnifying glass icon outside and to the left of the EditText like this:

and other times display the magnifying glass icon inside the EditText like this, much more like the search dialog:

Android AccountManager com.google auth token types

()

Several AccountManager methods accept a String authTokenType which controls the "They are requesting permission to" list in the Permission request activity.

Here are some available values of authTokenType for the "com.google" accountType:

Make iTerm always quit when closing last window

()

While iTerm is not running, run:

defaults write com.googlecode.iterm2 MinRunningTime -float 0

link

Android Menu vs Action Bar

()

The options menu in Android will be displayed differently in the UI of your app depending on the value of android:targetSdkVersion that you set in AndroidManifest.xml. If android:targetSdkVersion is not set, or is set to a value less than 11, you will always get a grid of up to six menu items in one or two rows near the bottom of the screen.

Syndicate content
by Wesley Tanaka