I am preparing a J2ME application,
Which is basically data capturing utility, Which reads data from end user from form and the data will be submitted to server as the application will get connection.
I am planning to capture photo also.
Now my arch. is MIDlet will fetch data from user and will store it in RMS and as the connection is available the data will be submitted to server and it will be removed locally.
The main question is is it reliable to use RMS to store data.
My one data entry will be something like + a photo[optional]
"asdjbdabhsdfjkbahsdkfbakjsdfhasfjasdfhjasdlcjalmsdhfjasdfajksdlmcfjkanmsdfgsahjkcnfhs"
suggest me arch. changes.
I'm really struggling to understand your question.
if your asking if RMS is a reliable storage method for pictures the answer is yes.
You just have to convert your image to a byte array and save. Then when you need to make it back into an image, the Image class has a constructor for making a new Image from byte array anyway. The RMS is persistent so your data will be there if you stop the app and as a default your applications RMS should only be accessible to your application (although I think you can change this manually).
I'm currently developing a peace of software witch stores pictures, audio recordings and ID strings as well as date and time stamps on the phone it's self prior to a server upload point and I use the RMS.
I'm not actually sure if there's any other form of local storage that J2ME has access to.
Related
I would like to create an app where I could save text, image and audio notes to an offline database(without internet connection) and then show them in a list-like layout. Wouldnt like to save the files to internal storage directly.
Its my first time creating mobile app so I need help in choosing the right database for such use case. Any suggestions?
I think you may be confusing some terms.
While you can put all sorts of media in a database. Sometimes it not the most practical solution. It sounds like you might be thinking of file storage, not a database.
Further more, the files have to live somewhere, if not on a external server/database, than they will have to reside locally on the device. Your app will not have a local database service running just so that it can store media files. This would be a lot of overhead and take up a lot of resources.
the first thing to know: the database in android is SQLite, So any other offline database it's just a layer for managing the SQLite database, and It only saves numeric and text data, but you can save any other type like image, audio, array...Ect by creating convertors to save it in the database.
E.g: You can save BitMap-Image type- by converting it to ByteArray-List of 0s and 1s-, then converting the ByteArray to String-Default text type-, then you can save it to the database, and when you want to select the value, just convert by the opposite (String -> ByteArray -> BitMap), So the trick here is to know how to convert between the types.
Now the answer:
the best offline-database is RoomDatabase, the fastest way to create and manage SQLite database, with Room you don't need to build an SQLite database from the scratch, it's going to build it for you, and has a great way to create converters.
but for you as a beginner, standard SQLite is more than enough, if you will see RoomDB more difficult.
I am currently working with Fragments, one of my fragments is "User Profile" where the signed in user can edit and view their own profile. One of the requirements for this university project is that the user needs to be able to upload a profile picture and it should be allocated to their user profile and saved on the server (I am currently using Lampp on linux). I have the following questions:
When a user uploads an image using the Volley library (Android) does it first need to save the relative/absolute path of the image to the MySQL database, and then use this information to get the image in JSON format back onto the device, where it shall be cached?
I read online that the Volley library can cache images and videos on the device, which would help data consumption so the user doesn't need to download the image(s) every time they login again. But what if the user logs into the application from say an IOS device and uploads an image there and then they come back to the Android device and logs in there - the app needs to update their user profile.
My thinking was every time a new Image is uploaded to the server the time it was uploaded would be added to a Date/Time slot in the DB, then this time is stored is the SQlite DB and the MySQL DB, every time they open the application it makes a request to the MySQL DB requesting this time field and if no images have been added then the SQLite time and the one just pulled from the MySQL database will be the same so no need to download any images - I thought this would be a simple way of checking without using a lot of data? or is there a better option someone could suggest.
However, the problem with my above suggestion is say for example there are 5 images cached on the device, but a 6th one was added from another device, when we go back to the original device how do we only download the new image? and not all of the other 5 also which are already in the cache?
I think you need to store in db not path to image file, but URI that you pass into Volley. And then, when you want to show image pass saved URI in Volley and it will decide show cached image or upload from internet.
Good thoughts. I think in your case you can just show data cached in dp, and then additionally fetch data from server, and it was changed cache it and show new results. Also you can implements long polling, or sockets, or GCM to set up connection with server and fetch new updated data immediatelly (in real cases not immediatelly but faster then "go to app -> check from request if there was changes in server side").
And of course, please have a look to firebase tutorials to think about implementing on your server side this thing and provide more interesting and covenient connection with immediate update of your local cached data. additional link to video tutroial
For my current project, I would like to allow a user to create a sqlite database file and have them enter some content. Then the user has the option to sign into their google drive account and upload this file. Afterwards, after the user makes further edits, the new database file is uploaded to replace the old file. Finally, if the user has multiple devices, the database should be downloaded from the google drive and replace the existing file stored on the device.
Currently, I have successfully setup Google Drive SDK authentication and I can sign in to the app with my account.
My main question is, how do I upload a sqlite database file to the APP FOLDER when I choose to press a sync button? (This method should be called when the user needs to sync)
Additionally, how do I upload a sqlite database file to the APP FOLDER?
Your question is a bit broad, but I'll try to send you in the right direction.
First you have to decide if to use the REST Api or GDAA. Both will accomplish the same (actually the GDAA's functionality is a bit narrower now, but for your situation will do).
The big difference is that GDAA will handle on-line / off-line states for you, where with the REST Api, you have to implement some kind of non-UI thread (sync service) synchronization. Also, there are latency issues you must be aware when using GDAA.
Next, the process of uploading SQLite database is the same as any other binary data stream.
Grab the 'xxx.db' file, make output stream (or byte[] buffer) and create a GooDrive file with title + mimetype metadata, push the stream into it's content and send it on it's merry way. The only difference between a standard folder and an app folder is the parent of the file.
You get an ID you can subsequently use to download the file to the device. Or you can use search by metadata (title in your case) to get this ID. Again it comes as input stream and you dump it to an 'xxx.db' file on your device.
The second portion of your question deals with multiple devices. None of the apis will notify you about a change in GooDrive, so you must implement one of the 2 strategies:
1/ Polling (ouch), preferably in sync service with sync intervals the system gives you.
2/ GCM message broadcasted to the devices / users who are interested (not trivial, but efficient ... and sexy).
Another pitfall you must be aware when using multiple devices with GDAA is described in SO 29030110 and SO 22874657.
In case you decide to play with the 2 apis, I maintain basic CRUD implementation demos for both the REST and GDAA. The GDAADemo has also an option to work with the app folder.
Good Luck
i am building a application for a takeaway resturant using SOAP as a webservice.
Problem:
When i try to open the application it loads every time. and if i have slow internet it will take some time which is not good for a professional application.
How can i cache the images in my mobile so it loads automatically
Possible Solution in my mind:
i think i should use the local database and sink it with internet
Use local cache system (but what if the application close).
Use arraylist to store information.
Can you guide me in that as i am stuck i do some reading but i don't feel any reliable solution on it.
You can use some libs but you can lose images if the app is closed.
Actually you can cache images with libs and save them to sdcard at the same time. You need to save Their id in database. Then take data from sdcard by id from database in case you haven't internet.
This may or may not even be possible, but here's the situation: I want to use the ActionScript 3 Camera class to capture a video from a local camera (webcam, built-in camera, etc) and then play that video back within the flash application.
I'm considering the possibility of sending it to a Flash Media Server and then streaming it back as an on-demand video, but I would ideally like to keep the whole thing client-side for best performance.
I'm open to the idea of using a different platform (Java was one consideration) as long as it can be embedded in a web page, but I would like to keep development as straightforward as possible and make the process of accessing the application as easy as possible for the end user, which is why I chose Flash initially.
If anyone knows of a way to do this I welcome any input.
Okay, here's an update for anyone else who might be up against the same hurdle I was. I was able to accomplish what I wanted — to record a video, allow the user to preview it, then upload it from one flash application — by utilizing a utility written by Lee Felarca (zeropointnine — http://www.zeropointnine.com/ ) called flvEncoder.
The concept is as such:
Record audio and video data to raw format (much like Valentin Simonov suggested)
Pass the data to flvEncoder for encoding in Flash FLV format and get a ByteArray back. I know it seems redundant to say Flash FLV, but I word it that way because Flash and Adobe Media Player appear to be the only things capable of interpreting the result.
Create a NetStream instance and put it in Data Generation Mode, use the appendBytes() method to pass the encoded data to a Video object linked to an input NetStream.
Use FileReference.upload() to send the data to the server in an HTTP request.
It could potentially eat a lot of memory, but I only needed to record short videos anyway. I won't post the code here because it's messy and tied to a proprietary project, but I hope this information is helpful to someone. Thanks for the responses!
The easiest way would be to use FMS, Wowza or Red5 media servers. You just use NetStream to send data to your server, save movies there and stream back.
Also I suppose it is the only reliable way of doing it. Camera, Video or NetStream objects don't have access to actual video bytes. What you could do is to add an instance of Video to your Camera and draw it into a bitmap every 1/24th a second. After that you will still have to encode data or you'll run out ouf memory very fast. Here I'm not sure if there are any flv/h264 codecs made with as3 available. But anyway I bet it will be slow.