I'm new in android, I am developing web application by android studio.
When user open application, there is activity login. User need input ipaddress of server, username and password before access application.
What I want to know, Is it possible to save ippaddress and other data to something like SEASSON/Cookies Web in Android Studio? So user only need 1 time to input data, store it and ALL activity inside application will get that data everytime it needed.
Thankyou my friends.
If you want to keep the User's Login data locally, encrypt the values and store it in Shared Preferences or in SQLite Database.
I think storing it locally is the best option because it wouldn't require your app to make network calls every time user opens the app.
Here are my suggestions:
1. If you have a web service, encrypt and persist the values securely to your web service via a post
2. Encrypt and store the values in shared preferences
3. Encrypt and store the values in a sqlite data base on the device.
Related
I'm new to MySQL database and past week I was trying to understand sending and receiving data from android app to MySQL database. what I'm confused about and tried to find it by google or stackOverFlow or even youtube is that what is the best way to save android app user setting (like leveling up feature for specific user)to MySQL database. I can do it easily by shared preference if I had plan to do it locally but I need to save it to online database, so can I save SharedPreferences to MySQL?. what is the best way ?
If you need to store data online either use a given service or build your own API by implementing a backend you can then communicate with e.g. by https://github.com/square/retrofit with https://github.com/square/okhttp. You could have an API call which you just pass your SharedPreferences as JSON data and store it in a MySQL text type. But of course building your own API for just storing some preferences might be too much effort.
I Know If the User have to Store UserName and Password then we can create Class and store the UserName and Password in Class. At get the data using SharedPreferences for that class.But That class store the data upto we can not close the Application. If we close the Application then data will be destroyed.
My Question is :
I Want to Store Data in Application if the User close the application or Restart the Mobile device. But the data are Store in the Class. How to perform this task. I am new to android. Please Help me.
You are new to Android. So, you should go through this link. You got these many Storage options in Android: http://developer.android.com/guide/topics/data/data-storage.html
In your case, You can go with SharedPreferences. Your data will be stored in key-value pair. And also, it is persistent storage.
I'm trying to use SQLite Databases, but as I'm learning (via the internet), I'm getting really confused and I have a few questions.
Where is the data actually stored? For example, let's say I want a database that stores all the usernames and all the passwords for everyone who uses my application. I need to write this information onto the database, but where is it? Is it on the user's phone? Is it on the web somewhere? Whenever the user goes onto the app, I need to read from the database. Does it read from somewhere online or does it only read from the database created on the user's phone? Is there any way to create a static database that all users are able to write to?
If I'm using a SQLite Database to store username and passwords, do I need to secure it with a password? If so, how? I've read on some websites that this information can easily be read if it isn't secured with a password, but others tell me that it can only be accessed by my application.
SQLite Databases are used where you need to store the data of particular user or save his usage or some data which is permanent. This DataBase resides in the Android device. If you want to save the user accounts (say username & password) this should be done in the server (backend) and should get the data by using service calls every time.
Ex: You have a comic book application for which the user has to signup / signin. Then you maintain the user account in the server. After signup / signin, when user downloads a book to read. Make that book stored in the SQLite Database in Android device, so that it will be available forever.
If you try to maintain user accounts in the SQLite DataBase, you cannot get data of all the users an store in one Android device. So global data should be on server and Local data should be stores in SQLite DataBase.
1)straight answer is: When u use SqLite database in android application, in the sense your application have sqliteDatabase, means when u download that application in to your device then all sqlite database data stored in device.
2) For password security u have to encrypt password and store in sqlite database.
Which of the following ways is better to allow user to login once and avoid logging in again on next app launch?
1) Store just UserID and then just every time fetch data from server and load profile? (Problem: userID can be manipulated in SharedPreferences so user can easily hijack other users identity)
2) Store username and password in SharedPreferences then just auth user on every app launch and get users data from server? (Is this safe enough? )
3) On first login from device - store deviceID in online database and store userID in SharedPreferences, then on every app launch compare deviceID's and if matches = Fetch data and login automatically or if not matching = request login again?
Is there any better way perhaps? I would like to avoid using SQLite as for my app I have no need for database, my app is online MySQL database related and it's constantly communicating with it rather than having local database.
You could also send back a large meaningless id (such as a GUID) from the server on login. The server would store it in a list of valid login credentials. Store it on the phone also and send it back to the server for authentication. There would be no way to forge an id since it cannot be derived from any other information, and the chances of guessing one would be miniscule.
1) and 2) should never be done as it compromises on the security and any one with read/write privileges can easily view the sensitive information.
3) could work but not with the device id since that can also be manipulated on rooting. I would suggest you use the userid+password+deviceid to generate a hash and store that in your database. Consequently whenever you make any calls to your server use this hash to authenticate the user.
About fetching the data you need not do it every time. If the data is not very sensitive you can store it in your shared preferences and use it to reduce the network calls. You can use this to show the screen which opens on first time usage and consequently fetch additional data by making a network request. It would also not interfere with the user experience
I am trying to build a logging in system (stored in online database) for Android by email and facebook. Right now I coded the logging in for Android by email, but I am wondering how I should best code the part to remember if you are logged in or not the next time you open the app.
Is the best way to do this to simply keep track of this in a shared preferences file with a boolean? And should I store this just by username and then just get all the scored points of this user from the online database? Is it necessary to encrypt this data to my shared pref?
yes,shared preference is preferred way to do this.And why only store username,i mean store all the data in shared preference and then fetch it from there.there's no point in fetching it again and again everytime from server unless it is updatable.