seo優化排名, seo搜索引擎 | Google Android 手機程式設計--第七章:字串處理與XML, 資料儲存

seo優化排名, seo搜索引擎

網路推廣,網站排名,網站推廣,搜索網站,seo服務

Google Android 手機程式設計--第七章:字串處理與XML, 資料儲存

clock 十一月 6, 2009 22:59 by author Administrator

自從全球資訊網 Web 被建立以後,文字型的資料處理就一直是程式設計師所必需具備的基本技巧,目前最常見的三種文字處理技術是:

1. 字串物件

2. Regular Expression 比對

3. XML 文件處理.

 

Android 中的字串相關函式庫

java.lang

java.text

Android.text Provides classes used to render or track text and text spans on the screen.

Android.text.method Provides classes that monitor or modify keypad input.

 

Android.text.style Provides classes used to view or change the style of a span of text in a View object.

android.text.util

 

正規表示式

java.util.regex

處理XML 文件

android.sax

javax.xml.parsers

org.json   

org.w3c.dom   

org.xml.sax  This package provides the core SAX APIs.

org.xml.sax.ext  This package contains interfaces to SAX2 facilities that conformant SAX drivers won't necessarily support.

org.xml.sax.helpers  This package contains "helper" classes, including support for bootstrapping SAX-based applications.

 

資料儲存

 

共用資料 – SharedPreference

 

1  SharedPreferences

Preference Android 中用來儲存資料最簡單的一種方法,我們可以使用 Context.getSharedPreferences() Activity.getPreferences() 取得儲存的變數,或對某一 Preference變數的 editor 物件進行 put 動作以儲存資料,但這些共用資料只能在同一個 Package 底下使用。

 

以下是使用 Preference 來設定一個小計算機中按鍵模式keypress 的範例程式:

public class Calc extends Activity {

public static final String PREFS_NAME = "MyPrefsFile";

     ...     

 

    @Override

    protected void onCreate(Bundle state){        

       super.onCreate(state);

   

    ...

   

       // Restore preferences

       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

       boolean silent = settings.getBoolean("silentMode", false);

       setSilent(silent);

    }

   

    @Override

    protected void onStop(){

       super.onStop();

   

      // Save user preferences. We need an Editor object to

      // make changes. All objects are from android.context.Context

      SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);

      SharedPreferences.Editor editor = settings.edit();

      editor.putBoolean("silentMode", mSilentMode);

 

      // Don't forget to commit your edits!!!

      editor.commit();

    }

}

檔案系統 - Files

 

2  Files

Context.openFileOutput() and Context.openFileInput()

If you have static files to package with your application at compile time, you can save your file in your project in res/raw/<mydatafile>, and then get it with Resources.openRawResource (R.raw.mydatafile).

資料庫- Sqlite

3  Sqlite

To create a database, use Context.createDatabase() and Context.openDatabase(), and read and write this data as appropriate.

資料提供者 – ContentProvider

4  Content Provider

Android 中要跨越應用存取資料,Content Provider 是唯一的方法,Content Provider 是可以被所有應用存取得一種物件。

推薦給同仁

Tell a Friend 

您想要瞭解更多的免費小竅門以便提升你的網站排名嗎?
請馬上聯繫我們網站管理員:
MSN: chenlinwu@cmmail.com 
Email: info@rank-ad.com


第一個評分

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


開始建立您的網上業務,點擊進入

加入每二週免費網上推廣提示電郵訂閱,即時獲贈免費關鍵字廣告課程及提升網站流量

加入每二週免費網上推廣提示電郵訂閱, 即時獲贈免費關鍵字廣告課程及提升網站流量
Fo Xuan Henry

建立你的 Facebook 電子名片

Bookmark and Share

Twitter Updates:

評論

新增評論


(將顯示您的Gravatar圖示)  

  Country flag

biuquote
  • 評論
  • 線上預覽
Loading





© 版權所有 海神科技有限公司

© 版權所有 海神科技有限公司