Android : Is it possible to use my data after closing my application - android

I have stored some phone number in my application.
I want to do some operation like when i get message from that stored number then I want to send the automatic reply.
Once if we close our application then whether the data will be available or not?
After closing application I want to perform this operation with the data which I stored already.
Is it possible?

If you want to store small information use shared preferences,
http://www.tutorialspoint.com/android/android_shared_preferences.htm
(Or)
If you want store table of bulk information use SQLITE database,
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/

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.

Proper way to store mobile numbers

I am completely new to android. I am trying to build an app, where the user can save few mobile numbers.(In setting activity of the app)
And I have a button in the main activity on clicking it i need to send a pre defined message to the contact numbers which was already saved by the user.
So should I write down the numbers entered in a file internally or is there any other concept that will save the data entered by the user and use it for the apps further use
You can use SharePrefrence or Sqlite Database to save value, So that you can retrieve it later whenever required Tutorials to use are below:
SharePrefrences:
http://www.tutorialspoint.com/android/android_shared_preferences.htm
Database:
http://www.tutorialspoint.com/android/android_sqlite_database.htm
SqliteOpenHelper suits best for this case. You can store all the numbers in the sqlite database and there are number of tutorials for knowing how to use it.

Android - SQLite

I am trying to build an app that will use an SQLite database. My question is once the database is created, will all data still be there once the app is closed, i.e.: the database won't be overwritten when the app is restarted?
You, as a developer are the only one who have access to this database, thus it is only your code which will be allowed to change the state or content of this database.
Yes, the data will remain there.
The data will remain there because of your default create method. There is a status code. You can use SQLScout http://www.idescout.com/ to visualize the table and watch its change step by step.
Yes, data will remain in your application when you close the application. When you run the application the database create in the application.
But yes, if the user uninstalls, the application then user will lose the application. On the other hand, if you want to save the data when the application is uninstalled, then it's better to create the database in SDCard.

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

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