更多精彩: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()