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 第三方开源项目
  2. 详解Android读取本地图片和网络图片的方法
  3. android onSaveInstanceState的使用方法
  4. android获取sd卡路径方法:
  5. Android 数据库 短信 监听
  6. android中常见的二种数据解析方法----XML和Json
  7. Android SDK Manager无法更新解决方法

随机推荐

  1. Ubuntu 16.04编译Android,make 版本过高
  2. 针对Android 模拟器启动慢的问题
  3. Android NDK开发之旅38--FFmpeg视频添加
  4. android面试-面试知识点总结
  5. selector选择器
  6. android 图片占用内存与什么有关
  7. Android中ScrollView嵌套WebView
  8. Android之应用资源
  9. Android studio4.0 解决导入包Error 报错
  10. android 当环境配置发生变化 例如语言 屏