安卓应⽤开发常⽤代码1,获取当天⽇期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String updatedate = sdf.format(new java.util.Date());
2,String转Int
Integer.valueOf(str).intValue()
3,Int转String
String.valueOf(selectedtaskid)
4,Toast显⽰
Toast.makeText(ListComplicateTaskActivity.this, "你已经有100条记录,请先删除⼀些", Toast.LENGTH_LONG).show(); 5,不带参数跳转activity
startActivity(new Intent(ListComplicateTaskActivity.this,ListComplicateTaskActivity.class));
6,带参数跳转activity
A:
Intent it = new Intent();
it.putExtra("selectpos", 65535);
it.setClass(ListComplicateTaskActivity.this,AddTaskActivity.class);
startActivity(it);
B:
Intent intent = Intent();// 得到⽤于激活它的意图
position = IntExtra("selectpos", 0);
7,SQLite数据库操作
//查询
Cursor c = db.rawQuery("select * from task where taskid = ?",
new String[] { position + "" });
//插⼊
sql = "insert into task(taskid,content,priority,istop,isdeadline,deadline, updatedate) values ("
+ taskno
+ ", '"
+ stredit
+ "', "
+ radioidx
+ ", '"
+ isontop
+ "', '"
+ isdealine
+ "', '"
+ time + "', '" + updatedate + "')";
//更新
sql = "update task set istop = 'true' where taskid = "
+ selectedtaskid + "";
//删除
安卓开发实例入门db.delete( "task","taskid = ?", new String[] { String.valueOf(selectedtaskid) });
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论