Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:28:53+00:00 2026-05-31T23:28:53+00:00

I have read many questions about Android, J2ME and RecordStore , but I still

  • 0

I have read many questions about Android, J2ME and RecordStore, but I still can’t find the answer that could satisfy me.

I need to implement low-level part of my Java app that should work on different platforms, right now this is Android and J2ME, and in future it should work on PC too. I need to store simple data sets, that is almost similar to RecordStore in J2ME:

App should own several record stores with records, each record has:

  • the id (but it should be “my” id, not auto-returned one as it is in RecordStore),
  • the data (just a byte array).

I think I should write an Interface with needed methods, and each platform should have its own implementation of this Interface.

But this task seems to be very common (at least, for Android + J2ME), so, maybe there already is some lightweight implementation? I’m asking just because I don’t like to re-invent the wheel.

And maybe some suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:28:54+00:00Added an answer on May 31, 2026 at 11:28 pm

    So, I wrote interface that does satisfy my requirements, with two implementations: for Android and J2ME.

    Here is how does Interface look:

    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;
    
    }
    

    There is also a factory for data stores:

    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;
    
    }
    

    Docs auto-generated by Doxygen can be found here.

    Mercurial repository with Interface and all the implementations can be found here.

    How do I use it:

    As I already said in my question, I have app for Android and app for J2ME, both these apps does the similar thing. (if anyone interested, they does communication via bluetooth with remote embedded device)

    Both apps have common low-level part that does the main job.

    I have interface IMainApp, something like that:

    public interface IMainApp {
    
       public ISDataStoreFactory getDataStoreFactory();
    
       /*
        * ... some other methods
        */
    }
    

    Both apps (for Android and for J2ME) have its own implementations of this interface, and they pass its reference to the low-level part. When low-level part wants to open some data store, it uses ISDataStoreFactory returned by IMainApp.getDataStoreFactory. It works just like I want it to work.

    Hope it is useful for anyone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many questions about the facebook login but until not I didnt
I have seen many questions about the above topics but none that address this.
I read a lot about handling rotation in android applications, but I still have
I have read many answers to questions about dynamically resizing NSWindows and nothing has
I'm using Delphi XE2 with FireMonkey. I have read many other questions about MD5
sorry i have many questions about the lock/cache.=_=.. ->1. about cache, i know that
I have read a lot of gwt-mvp questions that are asked here, but since
I have found many questions here about storing values in viewstate, but haven't found
I have read many questions here about using mysql in background using php, and
I read about many old questions about this argument, and I thought that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.