I am new to Java and Android. I am just beginning work on an app that will save information to a server that someone else from within the same company can retrieve using the same app from a different android device. I know how to simply store data on a server using simple php scripts but this is a bit more complex and involves one user writing information to the server, while another user can see / download it. Within a company there would be multiple users who have acceess to this data. So my question would be, whats the best way to implement a company-wide database that ONLY members of the same company can have access to? Sorry if this seems obvious to some of you. I am just getting started and I have 7 books on android programming and none of them describe how to do quite what I am trying to do.
To do this you need to use Android network services to access data. In other words to retrieve a networked database information your device will connect to your service with a specified URL and arguments. In turn, the service will reply with the required data, say may be in XML format. All your app needs to do is parse the XMl and display the date as desired.
Same thing applies to putting data into the server, in this case however the data will be sent as arguments to the network service URL and the service will handle the persistence to a database.
My advise is to do a Google search of the keyword "Android Network Services".
Related
I'm developing a chat application in Java.
The architecture used is Server - Client(s) architecture.
The majority of the code is in Java, JavaFX for the GUI and PostgreSQL as the Database.
As this is a chat application (desktop), I'd like to know which is the best way to store chat history:
Locally in a text file, that the client has to read every-time
In the database as of type String (VarChar)
In the server as Lists
Some questions based on the three ways:
If a client connects from a different machine the text file will not be there
Is it possible to store every text entry in the database with a chatroomID?
How many objects can be stored in the server for as long as it runs?
Out of your three choices, I recommend you choose option #2 for storing chat history: A database, and here is why:
If you store the chat history locally in a text file, you run into issues such as how to sync with others. Also, you can modify the contents of the text file without going through your Java program (such as with an editor). If this file contains chats with sensitive information and someone has access to your computer, they can read it. This spells trouble.
Storing in a database is a great idea because it provides a central location for all your Java program. This is especially handy if multiple people are using your Java client, that way they can fetch chat history, as well as easily transfer chats to others! I wouldn't only use a type String (VarChar), but try to think of some other useful fields or columns that might be useful (i.e. timeSent, chatUserID, timeRead, etc). This also brings up the point that by using a database, you are able to set up some sort of user access rights (username and password) so that specific people can read specific chats.
If you store the chats on the server as a list within the Java server itself, and if your server restarts, you lose all your chat history. Bummer.
To sum up, keeping your Java client-server-database architecture is perfectly fine, and technically all 3 options could work, but databases is the way to go for storing your chat history! Even if setting up the database takes a little bit of work, it proves to be superior in efficiency and security out of the other 2 methods described since databases are built for archiving data.
I'm in a similar situation, I'm also developing a chat from 0, the only difference is that I'm doing it for iOS.
The way I'm developing my chat is:
I use an Ubuntu web server.
The server has a database in Mysql and the communication with the user is done through NodeJS.
In NodeJS I have a socket "Socket.io" which facilitates notifications between users.
On the iOS device, I store all the messages that it receives in Core Data, which is an extension of SQLite.
In order to obtain the pending messages depending on the device where the user is connected and I use an ID for each device, this ID is created and identified by the MAC physical address and thus what messages to obtain from the server and what not.
Initially I base myself on this database to know how to structure my application: https://github.com/yoosuf/Messenger
Socket.IO is incredibly easy to use and the best thing is that it has libraries for different programming languages, here is its page:
https://socket.io/
https://github.com/socketio/socket.io
I would say Nr2 - for safety reasons (if you care about it) and because it is a pretty easy way.
For the beginning a database with 4 columns should be enough (Date/Time, ChatroomID, UserID or just a name and the message itself). If a user sends a new message it creates a new row containing all the information that is needed for the columns. You can easily iterate through it as well when your client reloads (maybe every 10 seconds)
I am making an application similar to that of apps such as pay by phone and paymobile, which are apps used to pay for parking instead of using a parking meter and having to display a ticket in your vehicle.
I need to start with the back-end (the database) and was wondering if SQL would be appropriate for this app.
As SQLite is stored on the system (the Database) there will be data such parking details and payment details.
Will I be able to send this data to say my laptop which will act as the server for the traffic wardens device to check number plates?
Or would I have to use a sql software that is not on the applications itself?
Any thoughts and suggestions would be much appreciated :D
SQL is perfect for back end database needs. You can various flavors of SQL like Oracle or MySQL on the back end. As far as the application data being sent to the server (your backend laptop), that will be taken care by the application level programming. For android, there are various ways to send data, using the native class AsyncTask or using third party libraries like Retrofit and Volley. You need to take a decision depending on the architecture of your app.
Try this
Create database on your server
Create Web API like .Net MVC on your server
Create connection between your Web API and your database
In your mobile app you can use webservice to get our put your data to database
You can encyrpt your data on your database to more safety
do not use SQLite , because it is unsafe to keep your important data.
I trying to post data from android SQLite database to MySQL database. I come cross many reference. My question is can I post data from Android SQLite database to MySQL database without Json? Json seem very complicated since I don't have a any Json knowledge.So far I can store data in SQLite. I need to post all my data to MySQL. Thank You.
It is a good question.let maximum people get benefit out of this. When you are using a mobile either it could android,IOS,windows no matter what ,the device has to interact with the server in order to exchange the data stored in the server.If you want to browse you need an active internet connection. can you browse without internet on a mobile?? i don't think that technology exist. Similarly, there are only two ways how you can interact with server from mobile devices. XML JSON Typically these act as a bridge between two canals.
XML:
The data can be transferred from mobile to server and from server to mobile using XML.This is the traditional one.May be first evolved technology.But it is heavy weighted.
JSON
This is the advanced technology. Very Light-weighted,quick and easy to learn.Easy to parse. JSON is the common framework that is being used now-a-days.
And when it comes to your question:
you cannot cross canals without a bridge or a boat. which is JSON or XML in your case.
I'm developing a knowledge base java application, where I can store and retrieve annotations with its title, date when the note was created (SQL datetime), content, tags about the annotation, etc.
It can be done easily with a database (I'm using SQL Server 2014), but the main problem is that the server is running on my own PC and it has to be always on and running the SQL Server. Also, I would like to extend the application by storing and retrieving this kind of data on mobile apps for Android and iOS.
Is there any other way to store that type of data in some files so it can be uploaded to some cloud storage like Dropbox ? After storing it on Dropbox, all I would have to do is sync the app with dropbox, get the files and read/write stuff.
UPDATE: Thanks for all the answers they helped me a lot. The best solution for me is to replace SQL Server with SQlite, as Gabe Sechan commented. Now I can make changes on the database without the need of a server running 24/7 and I can use the same database on Android and iOS apps.
You can use just a basic ajax call to pull content from a Dropbox "public" URL.
function(contenturl,intoselector,callback){
if (contentwindow.currenttopic!==contentID){
jQuery.ajax({
type:'GET',
url:'//www.corsproxy.com/'+contenturl,
dataType:'text',
async:true,
success:function(data){
intoselector.html(data);
if (jQuery.type(callback)==="function")
callback();
}
});
}
Notice that this example pulls through corsproxy so that you don't receive any XSS errors, so the url you pass needs to not contain a protocol itself.
If you want to pull a JSON or XML string that is stored in the file, then you might need to play around with the dataType and contenttype options in the ajax call.
This can also be done using Google spreadsheets:
Reading:
Create a spreadsheet and publish it on the web
Use one of the many available Javascript libraries for pulling data from Google spreadsheets:
http://jlord.us/sheetsee.js/ (which uses Tabletop.js)
http://chriszarate.github.io/sheetrock/
Writing:
You can use a Google app script for writing to the spreadsheet (reference) OR
You can create a Google form linked to the spreadsheet and simply fill the form from your mobile app whenever you want to add some data to the sheet (reference)
Of all the cloud services, when it comes to Android, Dropbox's Sync API is one of the easiest to implement. Do you need specific code examples on how to sync with Dropbox?
Before downvoting, please note that I am only asking for expert opinion, and not the source code.
I am working on an android app which will sync contacts/sms/mms on a webserver.
Which of the web service technologies is suitable for this app and easy to parse on server side?
Is it correct to convert contacts etc to a text file before sending to the server as I may not be able to convert mms and picture messages to a text file?
I want users to restore their data from the server. Will there be any problem regarding data format while downloading data to mobile?
REST web services are generally the best way to go for mobile devices as they are light weight meaning they require less processing and phone resources to use when parsing responses in JSON.
Heres a link to a question that deals with accepting an attachment over a REST web service in java
How do I write a restful web service that accepts a binary file (pdf)
However REST isn't as secure as SOAP, given its going to be personal data you may want to consider this. Also from experience of whats been happening in the news with this kind of data being taken off of phones you may want to consider not doing this at all as it can become a data privacy law nightmare.