2014 年文章归档
共 24 篇文章
mysql初识之数据文件及其他文件 (转载 )
数据文件 在mysql中数据文件存放于在my.cnf中datadir指定的路径,使用的表引擎不同产生的文件格式、表文件个数也会有所差异。mysql的表引擎有多种,表的扩展名也不一样,如innodb用“ .ibd”,archive用“.arc ”,csv用“.csv”等。 myisam表引擎 myisam表会产生三个文件:MYI、MYD、frm文件 frm文件: 主要存放表的元数据(meta),包括表结构定义信息等。不论是哪个表引擎都会有一个frm文件,存放在数据库的数据目录下。 .MYI文件(索引文件): 主要存放myisam的索引信息可以被cache的内容主要源于 .MYI文件中,每个my…
2014-05-20 10:56
AIDL传输复杂数据示例
自定义一个Person类,并实现Parcelable接口,必须实现这个接口,实现这个接口,必须有一个静态变量CREATOR,具体查看 http://developer.android.com/reference/android/os/Parcelable.html public class Person implements Parcelable { private Integer id; private String name; private String pass; public Person() { } public Person(Integer id, String name, S…
2014-05-16 16:11 · android
AIDL传输简单数据类型示例
定义一个AIDL接口(扩展名.aidl): package com.example.aidlservice; interface ICat { String getColor(); double getWeigth(); } 定义一个service public class AidlService extends Service { private String color; private double weight; private CatBinder catBinder; Timer timer = new Timer(); String[] colors = new String[]…
2014-05-15 16:04 · android
service启动的两种方式和IntentService
启动一个service有两种方式: 通过Context的startService()方法:通过该方法启动service,访问者与service之间没有关联,即使访问者退出了,Service仍然正常运行。 通过Context的bindService()方法:使用该方法启动service,访问者与Service绑定在一起,访问者一旦退出,Service也就终止。 Caution:一个service运行在宿主进程的主线程中——service不创建自己的线程,并且不运行在一个单独的进程中。意思就是说,如果你的service打算做一些使用cpu密集的工作或者阻塞的操作(例如MP3播放或者网络操作),你…
2014-05-04 11:47 · android
activity四种启动模式
activity的四种启动模式: **standard:**默认模式,activity在每次启动的时候都会有一个新的实例加入到task中。 **singleTop:**如果在顶部已经存在一个activity的实例,系统就会通过调用 onNewIntent() 方法来启动,无需再此实例化一个activity。 **singleTask:**系统会创建一个新的task和一个activity实例在task的根部,如果activity已经存在单独的task中,系统就会调用 onNewIntent() 方法类,而不是进行实例化一个新的实例,仅有一个activity实例同时存在。 **singleIns…
2014-04-30 14:32 · android
android Fragment基础
创建一个Fragment 如果要创建一个Fragment,必须创建一个Fragment的子类(或者已经存在的子类)。一个Fragment看起来像一个activity。它包括和activity相似的回调方法,例如 onCreate() , onStart() , onPause() , and onStop()。 实时上,如果你要使用fragment转化一个已经存在的Android应用,你也许只要简单的将activity中回调函数中的代码复制到fragment的回调方法中。 一般情况下,你应该实现至少以下几种方法: onCreate() : 创建fragment的时候系统会调用这个方法。在你的…
2014-04-25 16:07 · android
Intent 的ACTION_CHOOSER和ACTION_PICK_ACTIVITY用法
ACTION_CHOOSER 用来显示一个供用户选择的应用列表,例如,你要打开一个视频,但是这个设备上有多个app都可以播放视频,这时候就会出现一个列表供用户选择,一般情况下是弹出式的。示例: Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); Intent intent2 = new Intent(); intent2.setAction(Intent.ACTION_CHOOSER); intent2.putExtra(Intent.EXTRA_T…
2014-04-24 14:53 · android
Intent和Intent Filters
Intent主要包含Componet name、Action、category、data、type、Extras以及flag。 Componet name 启动一个组件最直接的方式就是通过Componet name,也就是组件名称,它是一个 ComponentName 对象,指定组件可以通过一下几种方式: setComponent(ComponentName) setClass(Context, Class) setClassName(Context, String) setClassName(String, String) 其实下面的三种方式,最后调用的还是 setComponent(Co…
2014-04-24 11:15 · android
Android 异步加载一张网络图片
/** * 从网络上异步加载单个图片 * * */ public class LoadOneImageFromNet extends Activity { Button button; ImageView iView; String imageUrl = "http://image.club.china.com/twhb/7137652/2012/11/17/1353147018580.jpg"; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub …
2014-03-18 16:24 · android
BitmapFactory.Options 解决加载大图片OOM
当在android应用中加载一张高分辨率的图片时,十分容易出现Out of memory(OOM),这是由于内存溢出造成的,每个应用所使用的堆内存大小一般是固定的,有的是16M,有的可能会大些。那为什么这么大内存加载一张图片会溢出呢?原因就是android在加载图片的时候是使用位图来放到内存中的,那位图在内存中的占用空间计算就是 分辨率*每个像素占用的内存( ALPHA_8:每个像素占用1byte内存 ARGB_4444:每个像素占用2byte内存 ARGB_8888:每个像素占用4byte内存 RGB_565:每个像素占用2byte内存), 举个例子,如果一个图片的分辨率是1024*768…
2014-02-24 16:00 · android
android 使用getDrawable和BitmapFactory.decodeResource加载图片资源区别
在android中,使用this.getResources.getDrawable和BitmapFactory.decodeResource加载图片资源是有区别的,是用this.getResources.getDrawable方法加载图片资源时,无论对同一个资源加载多少次,堆内存的占用没有变化,也就是说再使用this.getResources.getDrawable加载同一个资源一次和加载100次,内存占用都是一样的(可能是共用一个堆内存,也就是你定义多个对象,但是这多个对象都指向同一个堆内存地址);但是使用BitmapFactory.decodeResource加载图片资源时,对同一个资源…
2014-02-21 11:49 · android
Java 内存分配全面浅析
本文将由浅入深详细介绍Java内存分配的原理,以帮助新手更轻松的学习Java。这类文章网上有很多,但大多比较零碎。本文从认知过程角度出发,将带给读者一个系统的介绍。 进入正题前首先要知道的是Java程序运行在JVM(Java Virtual Machine,Java虚拟机)上,可以把JVM理解成Java程序和操作系统之间的桥梁,JVM实现了Java的平台无关性,由此可见JVM的重要性。所以在学习Java内存分配原理的时候一定要牢记这一切都是在JVM中进行的,JVM是内存分配原理的基础与前提。 简单通俗的讲,一个完整的Java程序运行过程会涉及以下内存区域: l **寄存器:**JVM内部虚拟…
2014-02-20 10:56 · java基础
Drawable资源之LevelListDrawable资源
A Drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the drawable with setLevel() loads the drawable resource in the level list that has a android:maxLevel value greater than or equal to the value passed to the method. file loc…
2014-02-17 14:42 · android
Drawable资源之ScaleDrawable资源
A drawable defined in XML that changes the size of another drawable based on its current level. file location: res/drawable/filename.xml The filename is used as the resource ID. compiled resource datatype: Resource pointer to a ScaleDrawable . resource reference: In Java: R.drawable.filename In XML…
2014-02-17 14:25 · android
Drawable资源之ClipDrawable资源
A drawable defined in XML that clips another drawable based on this Drawable's current level. You can control how much the child drawable gets clipped in width and height based on the level, as well as a gravity to control where it is placed in its overall container. Most often used to implement th…
2014-02-17 10:55 · android
Drawable资源之ShapeDrawable资源
This is a generic shape defined in XML. file location: res/drawable/filename.xml The filename is used as the resource ID. compiled resource datatype: Resource pointer to a GradientDrawable . resource reference: In Java: R.drawable.filename In XML: @[package:]drawable/filename syntax: <?xml version=…
2014-02-17 10:40 · android
Drawable资源之LayerDrawable资源
A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top. Each drawable is represented by an <item> element inside a single <layer-list> element. file location: res/drawab…
2014-02-14 16:18 · android
Drawable资源之StateListDrawable资源
StateListDrawable用于组织多个Drawable对象。当使用StateListDrawable做为目标组件的背景、前景图片时,StateListDrawable对象显示的Drawable对象会随着目标组件的状态改变而改变。 file location: res/drawable/filename.xml The filename is used as the resource ID.compiled resource datatype:Resource pointer to a StateListDrawable .resource reference:In Java: R.d…
2014-02-14 15:29 · android
android value 资源
This page defines more types of resources you can externalize, including: Bool XML resource that carries a boolean value. Color XML resource that carries a color value (a hexadecimal color). Dimension XML resource that carries a dimension value (with a unit of measure). ID XML resource that provide…
2014-02-14 11:22 · android