How to read cookies in a Phonegap-based Android app with Java

Just took me forever to get this straight, here is the trick on how to do it: CookieSyncManager sym = CookieSyncManager.createInstance(appView.getContext()); CookieManager com = CookieManager.getInstance(); sym.sync(); String cookie = com.getCookie(“file:///android_asset”); if (cookie == null) Log.d(“MainActivity”, “Cookie is null”); else{ Log.d(“MainActivity”, “Cookie exists, value is:”); Log.d(“MainActivity”, cookie); }


Simple iPhone5 detection with JavaScript

It’s really simple, just use this function: function isIphone5(){ function iOSVersion(){ var agent = window.navigator.userAgent, start = agent.indexOf( ‘OS ‘ ); if( (agent.indexOf( ‘iPhone’ ) > -1) && start > -1) return window.Number( agent.substr( start + 3, 3 ).replace( ‘_’, ‘.’ ) ); else return 0; } return iOSVersion() >= 6 && window.devicePixelRatio >= 2 […]

.remove() and .contains() not working on your Java set?

If you suddenly experience problems callling set.remove() and set.contains() on your Java Set instances, you might be using Hibernate, which replaces your Set instance with its own version (PersistentSet), which uses a HashSet internally to store your data. For example, the problem I faced was the following: Person.java public class Person(){ String _name; public Person(String […]

Correct naming convention for boolean values in Hibernate mapping files

Ok, this just took me a while to figure out so I thought I’d share it here. If you have a boolean variable that follows the naming convention “isValue” (e.g. boolean isPerson = false;), then the according mapping file property name may not include the “is” part of the name, for example: <property name=”person” column=”is_person” […]