Recent Notes

Displaying keyword search results 71 - 80
Created by freyo on May 09, 2011 11:55:27    Last update: May 09, 2011 11:55:27
Reading from or writing to sdcard isn't any different from normal Java io operations. Just use Java io to open the file then read from or write to it. Android does provide some utility methods to lookup directories under the sdcard. Examples: // import android.os.environment File extDi... Example logcat output: D/Test ( 1353): External storage dir from Envi... To write to sdcard: try { FileWriter out = new FileWriter(new F...
Created by James on March 27, 2009 03:20:58    Last update: May 08, 2011 12:32:31
Use show create table <tablename> : mysql> show create table my_test_table; +------... Select from information_schema.table_constraints and information_schema.key_column_usage mysql> select * from information_schema.table_cons...
Created by freyo on April 12, 2011 15:13:32    Last update: May 03, 2011 15:20:55
Create new project $ tools/android create project \ > --package co... Edit res/values/string.xml , add strings for the main screen. <?xml version="1.0" encoding="utf-8"?> <resourc... Add widgets to main layout ( res/layout/main.xml ). <?xml version="1.0" encoding="utf-8"?> <LinearL... Edit src/com/android/apkinfo/GetAPKPermissions.java and change contents to: package com.android.apkinfo; import android... Install the debug package to the emulator: ant install The screen should look like: Add display permissions activity. Start by creating a new layout res/layout/display_permissions.xml : <?xml version="1.0" encoding="utf-8"?> <LinearL... Add the strings used by the new Activity ( res/values/strings.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc... Add the Display Permissions Activity ( src/com/android/apkinfo/DisplayPermissions.java ): package com.android.apkinfo; import android... Change src/com/android/apkinfo/GetAPKPermissions.java to invoke the Display Permissions Activity: package com.android.apkinfo; import android... Declare Display Permissions Activity in AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifes......
Created by jinx on May 03, 2011 11:43:26    Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected. Conversion rules: Type String Value Boolean TRUE '1' Boolean FALSE '' (empty string) integer of float string representing the number Array The string 'Array' Object Result of __toString() if defined, error otherwise Resource 'Resource id #n' , where n is a number assigned to the resource. NULL '' (empty string) Example: <?php set_error_handler(function($errno, $errst... Results: bool(true) --------------------- strval: '1'...
Created by Dr. Xi on April 20, 2011 21:44:15    Last update: May 02, 2011 20:56:58
The String.format() method provides versatile formatting capabilities. This tutorial tries to present these capabilities in a accessible manner. The format string A format string can contain zero, one, or more format specifiers . The general form of a format specifier is: %[argument_index$] [flags] [width] [.precision]co... where things in square brackets are optional, and conversion is a character indicating the conversion to be applied to the corresponding variable value. The only required characters in the format specifier is the percent sign % and the conversion character. A simple example: public static void simpleFormat() { System.out... The Argument index The argument index is specified by a number, terminated by the dollar sign $ . The same argument may be repeated multiple times in a format string. Unindexed...
Created by jinx on April 29, 2011 13:43:13    Last update: April 29, 2011 13:44:34
List of functions testing variable type: Function Description is_bool Finds out whether a variable is a boolean is_double Alias of is_float() is_float Finds whether the type of a variable is float is_int Find whether the type of a variable is integer is_integer Alias of is_int() is_long Alias of is_int() is_null Finds whether a variable is NULL is_numeric Finds whether a variable is a number or a numeric string is_object Finds whether a variable is an object is_real Alias of is_float() is_scalar Finds whether a variable is a scalar is_string Find whether the type of a variable is string Test code: <?php class A { } $a = ar... Output: var_dump: int(1) ------------------------- i...
Created by jinx on April 28, 2011 14:32:58    Last update: April 28, 2011 14:32:58
Use the is_array function to find out if a variable is array. <?php $a = array( '1' => 'Apple', ...
Created by Dr. Xi on April 28, 2011 11:37:23    Last update: April 28, 2011 11:37:23
The Future interface represents the result of an asynchronous computation. Future provides methods to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. You call one of the three submit methods of ExecutorService to get a Future object: <T> Future<T> submit(Callable<T> task) <T> Future<T> submit(Runnable task, T result) Future<?> submit(Runnable task) Use the first two to retrieve usable results from the computation. The third option returns a Future that returns null upon successful completion. It is used to simply wait for the task to complete, much like Thread.join() . import java.util.concurrent.Future; import java...
Created by jinx on April 25, 2011 13:52:47    Last update: April 25, 2011 13:53:05
The PHP function isset determines if a variable is assigned a value. It returns TRUE if a variable is set and not NULL . Example: <?php $a = "not empty"; $b = ''; // t... A nice little function to assign a default value if a value is not given: <?php function isset_or(&$check, $alternate = N...
Created by jinx on April 25, 2011 12:43:40    Last update: April 25, 2011 12:43:40
Use the PHP function method_exists to check if the class or object has a certain method. It returns TRUE if the method exists (even when the value of the property is NULL), FALSE if the method does not exist. Example: <?php class A { var $p = 'A property'; ... Outputs: Class A has method f1: bool(true) Object $a has... Also note that C++-like method overloading does not exist in PHP. Thus there's no ambiguity about which version of the method exists, i.e., with no argument, with one argument... etc. The following code generates Fatal error: <?php class A { var $p = 'A property'; ...
Previous  3 4 5 6 7 8 9 10 11 12 Next