Skip to main content

Implementing cache in mobile (J2ME)

We can maintain cache/history of our visited entries in our mobile.

The method that can be used is "RecordStore"
how to do it:
1) Open a recordstore
2) add records to it.
Note: They'll be stored into mobile memories, you can't see these records as such in mobile

Now, when you want to view these records, open the recordstore again if it's closed. just open each record and perform the function.
You can append these records in a list so as to show them as a history maintained.

Problem welcome...

Comments

  1. Hi, My team has come up with a very simple mobile app for devices having java or symbian o/s. The challenge is we need to store data in the LDS of the handsets since the users of such app may not be always connected to internet, its a GPRS app. We wish to know how to implement cache to store small data in the handsets. And how do we identify what data to store. you may mail me karabi.bharadwaj@gmail.com, thanks.

    ReplyDelete
  2. What I pre-assume that your mobile is java enabled and you are using J2ME to develop that app.
    Now, coming to your question
    1) how to implement cache to store small data in the handsets?
    There is already provision in J2ME for caching mechanism. The API that implements it is *RecordStore*. Basically whatever records/data you want to cache is stored in mobile's internal memory. It's not accessible to you. Once you run the app again then only you can view the cached contents.
    So, you can write a function to be called each time you enter some value inside your app, which can open the already existing cache data (known as record store in J2ME) and write it to your new record/data.

    2) how do we identify what data to store?
    It depends on your app what you want to actually cache. The most frequently used data is generally cached. So, it totally depends upon your requirement. e.g., I used to send messages to only 4 of my friends out of my 1000 contacts. Then ofcourse, I would like to use their contacts as frequently as possible instead of typing or searching the contact details again and again.

    ReplyDelete

Post a Comment

Popular posts from this blog

VBA MAcro to generate "table of contents with hyperlinks" automatically in a ppt

VBA MAcro to generate "table of contents with hyperlinks" automatically in a ppt: Function TableOfContent(count As Integer) 'count is the no. of slides in ppt Dim var As Integer Dim i As Integer, scount As Integer Dim strSel As String, strTitle As String, strb As String, strtemp As String, str As String Dim arr() As String Dim index As Integer, indexcount As Integer, slidecount As Integer Dim summary As Slide Dim para As Integer Dim slideOrder() As Integer 'To generate the Table of contents slide ReDim slideOrder(count - 2) 'Collect all the IDs of the selected slides For i = 1 To count - 2 slideOrder(i) = i + 2 Next 'Iterate over the slides in Index order slidecount = UBound(slideOrder) For scount = 1 To slidecount If ActivePresentation.Slides(slideOrder(scount)).Shapes.HasTitle Then 'Build up the ToC Text strTitle = ActivePresentation.Slides(slideOrder(scount)).Shapes("UseCase").TextFrame.TextRange.Text + ": ...

Filter packets through jpcap

//Open an interface with openDevice(NetworkInterface intrface, int snaplen, boolean promics, int to_ms) JpcapCaptor captor=JpcapCaptor.openDevice(devices[index], 65535, false, 20); captor.setFilter("tcp && src port 6000", true); It'll filter all the TCP packets with source port number 6000. So, all we need to do is pass the parameters and use logical and, or operators.

Upload a multi-part/image/file using curl

This post is about uploading a file to server using curl. Why I'm writing this post is because of a possible bug in Postman which forced me to look for an alternative to test my upload api. Test if curl is present in system : $ which curl /usr/bin/curl If curl is not present then install it : yum (centos), apt-get (ubuntu), brew (mac) Syntax of the command : curl -F "param1=value" -F "param2=value2" -F "filecomment=file_comment" -F "image=@image_path" server_api Here's an example of the same : curl -F "user_id=12" -F "description": "desc" -F "filecomment=This is an image file" -F "image=@/Users/Desktop/testim.png" localhost:80/myblog/create If using nodeJs, you can fetch the values in fields & files parameters.