..あなたが望む別のストレージのためのSQLite、RMS、でもWebサービスを実装することはできません私は、AndroidとJ2MEの2つの実装で自分の要件を満たすインターフェイスを作成しました。
public interface ISDataStoreFactory {
/**
* @param dataStoreId id of the data store
* @return ISDataStore with given id. Type of this id depends on target platform
*/
public ISDataStore getDataStore(Object dataStoreId) throws SDataStoreException;
/**
* Destroys data store with given id.
* @param dataStoreId id of the data store. Type of this id depends on target platform
*/
public void destroyDataStore(Object dataStoreId) throws SDataStoreException;
}
ドキュメント自動生成Doxygenのではhereを見つけることができます:
public interface ISDataStore {
/**
* Get number of records in data store.
*/
public int getNumRecords() throws SDataStoreException;
/**
* Get size of one record with specified id in bytes.
*
* @param record_id id of the record
*/
public int getRecordSize(int record_id) throws SDataStoreException;
/**
* Get record.
*
* @param record_id id of the record to read
* @param data byte array where to put the data
* @param offset offset in 'data' array from which should start to copy
*/
public void getRecord(int record_id, byte[] data, int offset) throws SDataStoreException;
/**
* Get record.
*
* @param record_id id of the record to read
*/
public byte[] getRecord(int record_id) throws SDataStoreException;
/**
* Resolves is record with specified id exists or not.
*
* @param record_id id of the record
* @return true if record exists, otherwise false
*/
public boolean isRecordExists(int record_id) throws SDataStoreException;
/**
* Put new record or update existing one.
*
* @param record_id id of the record
* @param data byte array of data
* @param offset offset in the data byte array
* @param length number of bytes to store
*
* @return true if operation was successful, otherwise false
*
*/
public boolean setRecord(int record_id, byte[] data, int offset, int length) throws SDataStoreException;
/**
* Delete the record.
*
* @param record_id id of the record
*
* @return true if operation was successful, otherwise false
*/
public boolean deleteRecord(int record_id) throws SDataStoreException;
/**
* Clear all the records.
*/
public void deleteAll() throws SDataStoreException;
/**
* Close the data store.
*/
public void close() throws SDataStoreException;
}
データストアの工場もあります。ここでは
は、インターフェイスの外観をどうするかです。
インタフェースを持つMercurialリポジトリとすべての実装はhereです。
どのように私はそれを使うのです:私はすでに私の質問で述べたよう
、私は、J2MEのためのAndroidアプリのためのアプリを持って、両方のこれらのアプリケーションは、同様のことを行います。(誰でも興味があれば、リモート内蔵デバイスとのブルートゥース経由の通信を行います)
両方のアプリケーションには、メインジョブを実行する一般的な低レベルの部分があります。
私はそのようなinterface IMainApp
、何かを持っている:(Android用およびJ2ME用)
public interface IMainApp {
public ISDataStoreFactory getDataStoreFactory();
/*
* ... some other methods
*/
}
どちらのアプリは、このインタフェースの独自の実装を持っている、と彼らは低レベルの部分への参照を渡します。下位レベルのパーツが一部のデータストアを開こうとしているときは、ISDataStoreFactory
が返され、返されるのはIMainApp.getDataStoreFactory
です。私はそれが働きたいのと同じように機能します。
誰にでも便利です。
私はRecordStoreがAndroidでどれくらいうまく動作しているかわからない...あなたの書き込みたい場合はヒントを教えてください – Baba
Androidには「RecordStore」はまったくありません。誰かにヒントを与えることができれば、それを与えることができるのではなく、すぐにそれを伝えてみましょう。 =) –