asynctask
An asynchronous task is defined by a computation that runs on a background thread and * whose result is published on the UI thread.
asynctask要运行的运算的结果将会返回到在ui 线程中
sharepreference到底该保存那些内容
在sharepreference中保存:
1.android的网络连接状况,系统信息等
2.有必要记录的activity操作
3.用户首次登陆,程序首次打开,重要网络操作的备注
4.本地数据库插入,删除的信息记录
5.一些service的调用情况,如syncservice同步服务,下载服务等
Retrieve and hold the contents of the preferences file 'name', returning * a SharedPreferences through which you can retrieve and modify its * values. Only one instance of the SharedPreferences object is returned * to any callers for the same name, meaning they will see each other's * edits as soon as they are made. * * @param name Desired preferences file. If a preferences file by this name * does not exist, it will be created when you retrieve an * editor (SharedPreferences.edit()) and then commit changes (Editor.commit()). * @param mode Operating mode. Use 0 or {@link #MODE_PRIVATE} for the * default operation, {@link #MODE_WORLD_READABLE} * and {@link #MODE_WORLD_WRITEABLE} to control permissions. The bit * {@link #MODE_MULTI_PROCESS} can also be used if multiple processes * are mutating the same SharedPreferences file. {@link #MODE_MULTI_PROCESS} * is always on in apps targetting Gingerbread (Android 2.3) and below, and * off by default in later versions. * * @return The single {@link SharedPreferences} instance that can be used * to retrieve and modify the preference values.
getSharedPreferences
关于Android中保存session
The CookieSyncManager is used to synchronize the browser cookie store * between RAM and permanent storage. To get the best performance, browser cookies are * saved in RAM. A separate thread saves the cookies between, driven by a timer.
The sync interval is 5 minutes, so you will want to force syncs * manually anyway, for instance in {@link * WebViewClient#onPageFinished}. Note that even sync() happens * asynchronously, so don't do it just as your activity is shutting * down.
同步内存中的cookie和永久保存的cookie
SystemClock时钟
<li> <p> {@link System#currentTimeMillis System.currentTimeMillis()} * is the standard "wall" clock (time and date) expressing milliseconds * since the epoch. The wall clock can be set by the user or the phone * network (see {@link #setCurrentTimeMillis}), so the time may jump * backwards or forwards unpredictably. This clock should only be used * when correspondence with real-world dates and times is important, such * as in a calendar or alarm clock application. Interval or elapsed * time measurements should use a different clock. If you are using * System.currentTimeMillis(), consider listening to the * {@link android.content.Intent#ACTION_TIME_TICK ACTION_TIME_TICK}, * {@link android.content.Intent#ACTION_TIME_CHANGED ACTION_TIME_CHANGED} * and {@link android.content.Intent#ACTION_TIMEZONE_CHANGED * ACTION_TIMEZONE_CHANGED} {@link android.content.Intent Intent} * broadcasts to find out when the time changes. * * <li> <p> {@link #uptimeMillis} is counted in milliseconds since the * system was booted. This clock stops when the system enters deep * sleep (CPU off, display dark, device waiting for external input), * but is not affected by clock scaling, idle, or other power saving * mechanisms. This is the basis for most interval timing * such as {@link Thread#sleep(long) Thread.sleep(millls)}, * {@link Object#wait(long) Object.wait(millis)}, and * {@link System#nanoTime System.nanoTime()}. This clock is guaranteed * to be monotonic, and is suitable for interval timing when the * interval does not span device sleep. Most methods that accept a * timestamp value currently expect the {@link #uptimeMillis} clock. * * <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNanos} * return the time since the system was booted, and include deep sleep. * This clock is guaranteed to be monotonic, and continues to tick even * when the CPU is in power saving modes, so is the recommend basis * for general purpose interval timing.
String 类型真是保存数据最终还是char[]
public final class String implements Serializable, Comparable<String>, CharSequence {
<p>
</p><p>private final char[] value;
</p>
Logger记录变量到console或文件中。
Loggers are used to log records to a variety of destinations such as log files or
* the console. They use instances of {@link Handler} to actually do the destination-specific
* operations.
android对本地数据库的操作都需要用到SQLiteOpenHelper这个类
创建一个数据库管理对象一般就是
private Database(Context paramContext) {
// 创建一个对象打开和创建和管理数据库
super(paramContext, "mydatabase", null, 11);
}
这段代码调用SQLiteOpenHelper的原型是
/**
* Create a helper object to create, open, and/or manage a database.
* This method always returns very quickly. The database is not actually
* created or opened until one of {@link #getWritableDatabase} or
* {@link #getReadableDatabase} is called.
*
* @param context to use to open or create the database
* @param name of the database file, or null for an in-memory database
* @param factory to use for creating cursor objects, or null for the default
* @param version number of the database (starting at 1); if the database is older,
* {@link #onUpgrade} will be used to upgrade the database; if the database is
* newer, {@link #onDowngrade} will be used to downgrade the database
*/
public SQLiteOpenHelper(Context context, String name, CursorFactory factory, int version) {
this(context, name, factory, version, null);
}
当新版本发布的时候想要修改数据库表结构,删除表创建表,可直接调用onupgrade数据库的版本号,
如果要降低版本号调用onDowngrade,在android创建sqliteopenhelper时会重新定义版本号信息,所以onupgrade,ondowngrade也是这时候被调用
getWritableDatabase 或者 getReadableDatabase 的时候
附带一篇android开发数据库管理对象参考文章http://blog.csdn.net/lidew521/article/details/8655229
android参考类sqliteOpenHelper的参考翻译http://blog.csdn.net/think_soft/article/details/7969122
对于sqlite的数据类型附带一份翻译http://blog.csdn.net/lxfjsks/article/details/5983682
在android中的SQLite数据库的操作,在初次使用程序或程序要更新数据库时都要创建表或对表结构修改。所以需要程序对数据库表进行修改
SQLiteOpenHelper类提供了两个重要的方法,分别是onCreate(SQLiteDatabase db)和onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion),前者用于初次使用软件时生成数据库表,后者用于升级软件时更新数据库表结构。
DATABASE LOCK
原因:1:多线程write
2:SQL事务异常,事务查询出错,事务查询游标没有关闭,事务没有结束
3:数据库没有关闭,二次打开
ClassNotFoundException: Didn't find class
检查manifest.xml文件,ADB cannot find运行android程序错误
命令行adb kill-server重新启动adbserver adb start-server重启eclipse即可android 常见分辨率
http://blog.csdn.net/sarsscofy/article/details/9249397