1. Database SQLite operation
Import Android.database.Cursor; Import Android.database.sqlite.SQLiteCursorDriver; Import Android.database.sqlite.SQLiteDatabase; Import Android.database.sqlite.SQLiteQuery; Import android.database.sqlite.sqlitedatabase.cursorfactory;//Create a database, Openorcreatedatabase is the method sqlitedatabase mydatabase=this.openorcreatedatabase (" Mydata.db ", Mode_private, New Cursorfactory () {@Override public Cursor newcursor (Sqlitedatabase arg0, Sqlitecursordriver arg1, String arg2, Sqlitequery arg3) {return null;}}); Delete the database, Context.deltedatabase (String) this.deletedatabase (dbname); Execute the non-queried SQL instruction String sql= "INSERT INTO test (ID) VALUES (i)"; Db.execsql (SQL); Execute Query instruction Cursor cur=db.rawquery ("SELECT * from Test", null); The IF (cur!=null)//cursor initially points to the first row {//Gets the column int numcolumn=cur.getcolumnindex ("id") of the ID, if (cur.movetofirst ()) {do{int val= Cur.getint (numcolumn);//Get ID value}while (cur.movetonext ()); } }
2. Get screen information
Import Android.util.DisplayMetrics; Describes the structure of display information: density, height, width, font size displaymetrics displaymetrics=new displaymetrics (); Initialize Displaymetrics Getwindowmanager (). Getdefaultdisplay (). Getmetrics (Displaymetrics); int width=displaymetrics.widthpixels; int height=displaymetrics.heightpixels;
3. Hint Information
Import Android.app.AlertDialog; Prompt dialog box Alertdialog.builder dialog=new alertdialog.builder (this); Dialog.settitle ("hint"); Dialog.setmessage ("Android hint"); Dialog.show (); Prompt short message, no interactive import android.widget.Toast; Maketext (Context,charsequence,int), the int parameter is displayed for how long/The system band has Toast.length_long,toast.length_short Toast.maketext ( Helloactivity.this, "Android Tips", Toast.length_long. Show ();
4.Activity jumps between
The starting activity is set Intent next_intent=new Intent (); Data transfer between the activity Bundle bundle=new Bundle (); Bundle.putstring ("username", Edittext.gettext (). toString ()); Next_intent.putextras (bundle); Specifies the jump Next_intent.setclass (Helloactivity.this, Nextpageactivity.class); StartActivity (next_intent); Objective activity to obtain data Bundle bundle=this.getintent (). Getextras (); String username=bundle.getstring ("username");
5. Jump to the specified Web site
Import Android.net.Uri; Open Web page Uri uri=uri.parse ("http://www.baidu.com"); Intent intent=new Intent (Intent.action_view,uri); StartActivity (Intent);
Cond