1. android activity 不会展示 title appname之类的方法

android:theme="@android:style/Theme.NoTitleBar"

2. openOrCreateDatabase

Context.openOrCreateDatabase 与 SQLiteDatabase.openOrCreateDatabase本质上完成的功能都一样,Context.openOrCreateDatabase最终是需要调用 SQLiteDatabase.openOrCreateDatabase来完成数据库的创建的。

也就是说, SQLiteDatabase类是android上对sqlite的最底层的封装,几乎所有的对数据库的操作最终都通过这个类来实现。

而Context里面提供的方法,是用于上下文的时候创建数据库,例如你在某个逻辑里面创建的数据库只是在特定的context里面,对于数据库的权限,交由context来管理,而这个逻辑可能是会提供给不止一个context


至于SQLiteDatabase和SQLiteOpenHelper就更好理解了,后者只是一个抽象类,用来告诉你怎样使用SQLiteDatabase类而已,你完全可以自己基于SQLiteDatabase写一个自己的helper.


3. 界面返回按钮的事件

goback = (ImageView)findViewById(R.id.mysc_goback);


//返回按钮的函数
goback.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
MyScActivity.this.finish();
}

});

4. 得到网络文件大小的方法

HttpManager hm = new HttpManager(Const.IR_URL+ir_name);
long newsize = hm.getContentLength();//获取新文件大小

/** * 获取返回内容长度 * @return */public long getContentLength(){long len = -1;if(httpclient!=null && httpPost!=null && !httpPost.isAborted()){//设置httpPost请求参数及编码try {List<NameValuePair> params = new ArrayList<NameValuePair>();httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));} catch (UnsupportedEncodingException e1) {Log.e(Const.TAG, "getContentLength 输入参数编码有问题:UnsupportedEncodingException");return len;}//第二步,使用execute方法发送HTTP POST请求,并返回HttpResponse对象try {httpResponse =httpclient.execute(httpPost);} catch (ClientProtocolException e) {Log.e(Const.TAG, "getContentLength 服务器无应答:ClientProtocolException");} catch (IOException e) {Log.e(Const.TAG, "getContentLength 服务器无应答:IOException");} catch (Exception e) { Log.e(Const.TAG, "getContentLength 服务器无应答:OtherException");         }if(httpResponse!=null && (httpResponse.getStatusLine().getStatusCode() == 200)){//第三步,使用getEntity方法活得返回结果    try {    HttpEntity httpEntity = httpResponse.getEntity();    len = httpEntity.getContentLength();} catch (Exception e) {Log.e(Const.TAG, "getContentLength 返回结果异常:OtherException"); }}httpPost.abort();httpclient.getConnectionManager().closeExpiredConnections();}Log.d(Const.TAG, "HttpManager.getContentLength|len="+len);return len;}


更多相关文章

  1. Android(安卓)greenDAO 3.2.2简单使用
  2. android 开发中将十六进制 颜色代码 转换为int类型数值 方法 :
  3. Fragment总结
  4. android双击返回键退出程序
  5. android 数据库操作 GreenDAO 第三方开源项目
  6. 详解Android读取本地图片和网络图片的方法
  7. android onSaveInstanceState的使用方法
  8. Android中全屏无标题设置
  9. Android(安卓)电话拨号

随机推荐

  1. 不是Web开发者所关注的XML基础具体分析
  2. 关于XML文档的基本操作的实例代码分享
  3. Parse XML Tree 解析XML文件的代码实例
  4. 浅谈WEB页面工具语言XML(六)展望
  5. XML解析之DOM4J解析的示例代码
  6. 浅谈WEB页面工具语言XML(五)好处
  7. XML模式-详细介绍DocBook XML
  8. xml解析java基础的详细介绍
  9. 使用XML将机器内码转换为人们能够理解的
  10. XML模式-RDF的详细介绍