2011年9月7日 星期三

SDK 升級到 android-12 模擬器出問題

今天要寫一些程式到Galaxy Tab 10.1時把SDK升到API Level 12,啟動模擬器時出現了

invalid command-line parameter: Files\Android\android-sdk-windows\tools/emulator-arm.exe.
Hint: use '@foo' to launch a virtual device named 'foo'.please use -help for more information

問題點是發生在SDK資料夾的路徑問題,只要路徑有空白格就會出錯

C:\Program Files\Android\android-sdk-windows
改成
C:\PROGRA~1\Android\android-sdk-windows

模擬器就順利起來了

2011年8月1日 星期一

SQLite query in android application

在Android 裡使用SQLite,最重要的class 就是 SQLiteOpenHelper


重點來了

getWritableDatabase()


Database upgrade may take a long time, you should not call this method from the application main thread, including from ContentProvider.onCreate().




getReadableDatabase()


Like getWritableDatabase(), this method may take a long time to return, so you should not call it from the application main thread, including from ContentProvider.onCreate().




說實在的,在對資料庫的抓取或異動還滿難用的....





public Cursor query (boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)

Since: API Level 1
Query the given URL, returning a Cursor over the result set.
Parameters
distinct要不要 DISTINCT, TRUE/FALSE
table表格名稱
columnsnew String[]{"column01","column02","column03"};
selection "column01 = ? AND "column02 = ?";
selectionArgsnew String[]{"A","B","C"};

selection 與  selectionArgs 是配對的   
groupByA filter declaring how to group rows, formatted as an SQL GROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped.
havingA filter declare which row groups to include in the cursor, if row grouping is being used, formatted as an SQL HAVING clause (excluding the HAVING itself). Passing null will cause all row groups to be included, and is required when row grouping is not being used.
orderByHow to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.
limitLimits the number of rows returned by the query, formatted as LIMIT clause. Passing null denotes no LIMIT clause.
Returns
  • Cursor object, which is positioned before the first entry. Note that Cursors are not synchronized, see the documentation for more details.


一般QUERY
SQLiteDatabase db = SQLiteOpenHelper.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, new String[] { "COLUMN01","COLUMN02" },
"cCarBocePartsIdn LIKE ?", new String[] { key+"%" }, null, null, null);

2011年5月22日 星期日

狗熊迷路了...

我的HTC Hero狗熊機,送修回來後用個幾天突然間發現......狗熊迷路了.......
GPS完全收不到衛星訊號,原來那幾天都是靠基地台定位的.....


所以又送神腦維修了去找回路感了....

2011年5月10日 星期二

我的英雄變狗熊了

最近幫我的手機刷了許多的不同版本的ROM想要讓老英雄速度快一點
結果是有快一點....不過刷上癮之後就開始亂搞,砍掉一堆系統的APK看會不會快一點...

昨天又要重刷的時候,我也不知道幹了什麼蠢事......
從此HERO就安眠了......

2011年2月13日 星期日

變更Eclipse workspace的路徑

設定檔的路徑:
/eclipse/configuration/.settings/org.eclipse.ui.ide.prefs


#Thu Jun 17 15:13:08 CST 2010
RECENT_WORKSPACES_PROTOCOL=3
MAX_RECENT_WORKSPACES=5
SHOW_WORKSPACE_SELECTION_DIALOG=false
eclipse.preferences.version=1
RECENT_WORKSPACES=E:\\My Dropbox\\Android\\Developer\\workspace