If you play around with height and width for a android device you often need to convert between real pixel (px) and device indipenden pixel (dp, dip). The following methods are a easy solution to convert between px to dp private float px2Dp(float px, Context ctx) { return px / ctx.getResources().getDisplayMetrics().density; } private float dp2Px(float ..
Category : Uncategorized
To remove objects from an array in Java you have to make a List out of the array with Arrays.asList(), and call remove(object) on all the appropriate elements. Then call toArray() on the ‘List’ to make back into an array again. This is not terribly performant, but if you use it in a properly way, ..
In some cases it makes sense to disable automatic wordpress updates. For example if you want to have a special release of a running wordpress installation to check plugins or themes with this release. Or if are not ready to update to the latest version of wordpress or you want to update manualy…. The wordpress ..
Short answer Yes Long answer Shared Preference are saved in the file system of your device, and the Shared Preferences Mode defines whether other applications have the right to read or write the Shared Preferences or not. Android SharedPreferences with mode “MODE_PRIVATE”, “MODE_WORLD_READABLE” and “MODE_WORLD_WRITABLE” are possible in android. MODE_PRIVATE This is the default mode, ..
If you open a URLConnection with the Hypertext Transfer Protocol, the Object of URLConnection that is returned from openConnection is a HttpURLConnection. This class defines a method, which is able to access the status code of the http response. To get the status of your http reesponse, it is necessary to cast the URLConnection Object ..
Sometimes it can happen, that the app has to prevent android from taking a screenshot of the app. This can make sense if the app is being pushed into the background and/or for security reasons. So use FLAG_SECURE: getWindow().setFlags(LayoutParams.FLAG_SECURE, LayoutParams.FLAG_SECURE); This line secures against manual screenshots and automatic screenshots from the ICS recent-tasks history. You ..
If you want to try downloading something unless you have wifi. You can use the following code snippet to be able to check if wifi is enabled. You will be able to use the ConnectivityManager to get the state of the Wifi adapter. From there you can check if it is connected or even available. ConnectivityManager ..
A dialog can have a custom layout with buttons, text views, list, images, checkboxes, etc. You can create a layout for your dialog and show the dialog with the following simple method. The showDialog method can be a part of your activity class. In that case you don’t need to explicitly declare the context as ..
To reverse engineere the oracle database, you can use the Oracle data dictionary like follows. — Get table information from oracle DB select T.* from USER_TABLES T; — Get column information from oracle DB select C.* from USER_TAB_COLUMNS C; — Get constraint information from oracle DB SELECT cons.constraint_type, cols.table_name, cols.column_name, cols.position, cons.status, cons.owner FROM all_constraints ..
With the getAll function of sharedPreferences it is possible to save the shared preferences to a file. The following code example is probably the easyest way to do it. With the saveSharedPreferences method you can save all shared preferences a file to the root of your sdcard. Make sure your App has the following permission. ..