wesley tanaka

Tech

java.lang.IllegalStateException: attempt to acquire a reference on a close SQLiteClosable

()

"java.lang.IllegalStateException: attempt to acquire a reference on a close SQLiteClosable" can occur in an Android program if you try to do an operation (like run a .query()) on a SQLiteDatabase object which has already been

Regression testing sqlite database migrations in Android

()

One strategy to test Android sqlite database upgrades is to make a copy of your SQLiteOpenHelper class each time you create a new database version. That way, you can use the older revisions of SQLiteOpenHelper to create legacy versions of your database schema and make sure that when you open the database with newer versions, the upgrade works properly.

3D models from a single photo

()

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:

Syndicate content
by Wesley Tanaka