更多精彩:guozeyiblog.cn
Android 數據庫
SQLite
初始化:openOrCreateDatabase(String path,null)
SQLiteOpenHelper
==>oncreate()//建表時調用
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen.
==>onUpgrade()//更新時調用
Called when the database needs to be upgraded. The implementation should use this method to drop tables, add tables, or do anything else it needs to upgrade to the new schema version.
Activity 三種狀態 => 運行 暫停 停止
七個過程 =>
Activity間的交互 1 發送端 =>Intent i.putExtra("鍵","值")
接受端 =>getIntent().getStringExtra("鍵");
2 發送端 =>Bundle data= new Bundle();
data.putXXX("鍵","值")
Intent i.putExtra(data);
接收端 =>XXX a = Bundle data=getIntent().getExtras().getString();
反向傳值:
主文件: 以StartActivityForResult(Intent)打開 重寫回調函數onactivityResult()
附文件:setResult(int,Intent);
Server
啓動 startServer(Intent(MainActivity.this,server.class));
終止 stopServer(Intent)
server.java 繼承自server 需要重寫Oncreate() ondestory();
bindServer()
unbindServer()
利用startServer開啓的服務在Activity終止後服務不會停
bindserver綁定的服務會終止
廣播:sendBoradcast() registerReceiver() unregisterReceiver()