Archives : March-2015

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, ..

Read more

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 ..

Read more

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 ..

Read more

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 ..

Read more

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 ..

Read more

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 ..

Read more

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. ..

Read more

Google has started to use ripple animations in Material Design UIs. The setHotspot() method is added in API Level 21. This teaches the drawable a “hot spot”, and the RippleDrawable apparently uses this as the emanation point for the ripple effect. The setHotspot() method of a view take the x,y values from the MotionEvent to ..

Read more

If you have to create an object with default constructor, you can invoke the newInstance() method on a Class. This simple class creates the instance of a named class using the empty default constructor by calling the newInstance method: public class ReflectionTester throws InstantiationException, IllegalAccessException, ClassNotFoundException { public static Object createObject(String className) { return Class.forName(className).newInstance(); ..

Read more