Best way to save data in android - android

I am creating an chat program that communicates with my server at home, so I can send commands. I was wondering what is the best way to save the login information? database? shared preference? sqlite database? file(xml,txt)?
what do you guys think and why?

You can take a look at this article: http://developer.android.com/guide/topics/data/data-storage.html
In my opinion, the best way will depend on the amount of data, if you want to save your login information I'd use SharedPreferences, but if you want to save the login information of many people, I think of using a sqlite database.

Login information contains passwords also, so I would consider this security problem choosing the location to save data.
Login information is usually stored in the server and not in the client: I would definitely choose to store them in a DB.
I suggest to encrypt passwords if you want to save them in a DB (SQLite, MySql or whatever).
For further information I suggest to take a look here:
Android: Storing username and password?

Related

Android applications with SQLite: is sqllite data stored locally on the phone only?

... or can I acess it remotely? If yes, where/how?
To illustrate my question with an example:
If I want to implement a login function and an user creates an account: will his login information only be stored on his phone? (So he can only login on his phone on nowhere else?) Or is it stored somewhere else?
I'm quite confused at the moment and wasn't able to find good ressources zu answer my question (maybe someone knows a good tutorial?)
Thank you in advance for your answers!
There are mainly 3 ways to store data in android:
With the shared preferences, you can save data locally. Its limit is that when you close your app the data are deleted.
With SQLite the limit of the shared preferences is overcome. You can save data into a binary file stored locally in your phone. For use it you have to write some specific java code and inside it write in SQL sintax. It is used for example to keep the highest score in single player game, or simply to let the app remember description, text, user inputs.
With Firebase you can save data in a not local way, data are stored in a server. You can use it for example for develop a social, a game that need to share data with more users, when you have a multiuser application.
This is a data file storage overview, it could be useful too.
For login data it's better to use share preference instead of SQLite. If you use SQLite or Room or share preference, data are saved locally and you can't access them remotely.

The best way to save and edit User Information within my Android App

I am trying to save and store a user's picture, name, contact information and company address. I want the user to add and edit his information at his convenience.
I wonder what will be the best possible way to do this?
Can we do this through sharedpreference? How about internal storage? Or will it be SQLite? I am not so sure which data storage will work best since i am only saving the user's information. It will not be a list or directory.
And if you can share sample codes and projects, I would really appreciate it.
Thank you.
Use sqlite for better persistence. You will find that the user clearing cache will not affect the saved values.
If you store picture in Base64 format you can use SharedPreferences . If you want to store images etc. i will suggest you to use Sqlite. Generally search for Sqlite and SharedPreferences will help you:
Sqlite tutorial : Sqlite
Shared preferences working like key, value pairs: Shared Preferences
You can store user data with storage option in android shared preference or sqlite database
preferable way is to store User information like password or such data in encryption mode
for multiuser api 17 supports User Manager

Android Storing Data

I am creating a community app where people can have a profile and search for people - like the soical network kind.
Which is the best way to store data of the logged in User like - User ID, name etc. so that i can use this across the activities for showing data and doing Api calls to get data across the application for the user related content.
What i want to store Locally
User Details like -> userId, Name, Last Known localtion, gender, birthday
Messages Inbox -> threads of conversations between two people.
You can use either SQLite Databases or Shared Preferences Using SQLite Databases will be better If you want to store more information ina astructured manor. But to save small information you can use Shared Preference
Well I guess the best approach is to store data in a database (SQLite), and use a call to sync the data with the server. Like this you can use your app even if you are offline :)
If you store data in memory when you have no internet connection, or you have an internet connection problem, you will get into a lots of trouble.
Good luck,
Arkde

Android where to store credential info like url, username, passcodes?

I have an app which will connect to server and provide some basic connection credential information like server url, userer, application id etc What is the best option for storing this information within the android app? Should it be a preference? not sure where to store these items. I should clarify this question a bit. There are different levels of security requirements, so I am interested in hearing about how to encrypt the password etc, but there are also items which are generally not encrypted like connection urls etc, so I am also interested in how to store such information as well. I am basically looking for a better solution
You can programatically CRUD SharedPreferences to store this information. PreferenceManager.getDefaultSharedPreferences is one way to access them. Read this guide to get started: http://developer.android.com/guide/topics/data/data-storage.html#pref
Android will prevent other applications from accessing whatever you store in SharedPreferences or a SQLite database. In either way, you are still storing information in the clear. If an attacker gains root access, they can read that information.
Update - I couldn't find this earlier, but here is some sound advice from Reto Meier: What is the most appropriate way to store user settings in Android application
You want to use an HTTPClient and store these values in session cookies (handed out by the server).
These cookies are automatically managed by the HTTPClient whenever you make a request until the cookies expire.
DO NOT DO NOT DO NOT store this information in a local database or in Preferences. Anyone that plugs that phone into their computer can browse the database extremely easily if they are so inclined.
I think preferences is the best. Storing in SQLite database might not be secure.
Databases can be pulled out and accessed(also using SQLite Editor apps), but preferences cannot be accessed by any other applciation.

How to store data from my app

Actually i want to know how to store data from my app in the device so that i can review the store data when i run the application again..
means in simple terms i want to say that suppose i have text box where i write some information..now when i click the submit button, this information will be save,so that when i open the application the stored data should be appear in the text box..
In all terms i want to say that i just want to stored data in the way that we are using database for storing data..so please anyone suggest me how that can be done in android.
if possible show with an example
Regards
Anshuman
If you have to store small amount of data, you can use SharedPreferences in Android.
If the data that you have to store is big/complex enough, try using SQLite database.
Still need help?
UPDATE: There's a tutorial that I wrote to demonstrate how to use SQLite database. check it out here. Although it copies existing database into device's memory, but other versions of it, which create database through code can also be devised from it.
A better tutorial is here : http://www.vogella.com/tutorials/AndroidSQLite/article.html
1) If you want to store data in table format then you can use SQLite database in android
2) If you don't want to store data in table format then you can store in SharedPreference
more info about SharedPreference here and here
Android comes with a built in SQLite database that you can use. I advice you to go trough this notepad tutorial. It teaches the basics of using Android SDK including different states of the android application as well as how to use SQLite with Android.
For storing simple key = value pairs, you can use Properties.
For data storage as in a database, you can use sqlite on android.
Android provides several options for you to save persistent application data. The solution you choose depends on your specific needs, such as whether the data should be private to your application or accessible to other applications (and the user) and how much space your data requires.
Your data storage options are the following:
Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Network Connection
Store data on the web with your own network server.
Data Storage

Categories

Resources