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.
Related
... 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.
I have a phone application that uses a database of words and tests a user to see which words they know. I have a SQLite database with the words that I populate using a console application and this is then deployed as a resource to phones etc.
When the user runs the application then it stores pass fail data in the same database but in different tables.
When I update the application a fresh copy of the words database is installed on the phone and all the user data is lost.
How is this typically handled? Do phone applications that use SQLite have multiple databases with one being used to store user data and the other holding data which can be brought in when the application is first installed or updated?
If multiple databases are used then is it possible to create a look up from one database to the other?
Thanks in advance for any help, advice or links that point me in the right direction.
I would use a file (JSON, or plain text) to ship the words with the app. Then, when the app runs, it reads that file and adds the new words to the database. This won't affect the other tables.
Instead of having to deal with that, we hard code the values into a static method in code. Then at runtime, we see if there is any data in the table and, if not, we grab the hard coded data and do an insert.
In your case, I would also just add a version number of some kind so then, if the version was lower or the table was empty, you do a delete all and then insert your new static data.
This question already has answers here:
How to store data from my app
(5 answers)
Closed 7 years ago.
I want to create an application in which the user have two edittexts. Whenever the user types in the edittexts, I want to store it and retrieve when the user wants it. Also the user should be able to store as many files which contains his data as possible. How to do that in android?
Just get the text from your EditText:
yourEditText.getText().toString()
Then use SharedPreferences to save and retrieve the data as needed
There are a few options you have when it comes to storing data in Android.
The most simple way would be storing values in SharedPreferences, but I wouldn't advise trying this because
the user should be able to store as many files which contains his data as possible
So, you've got a couple other options
1. Saving Files
You could save one or more files to the users phone, and read it back in when the user wants to retrieve it.
2. Saving Data in SQL Databases
You could use a SQLite Database to manage the data in a more structured way.
Saving data to a database is ideal for repeating or structured data, such as contact information.
In your case, it really depends on what you are planning to do with this app. If you feel that you may expand the information the user can save, I would say go with a database. If you are sure that you will only need the info from the two EditTexts I think writing to files would suffice.
Depending on your use case you have basically three choices in Android to store data:
Shared preferences
Create a file in the file system
Use a database
Further information about each option can be found here: http://developer.android.com/training/basics/data-storage/index.html
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/
For my newest app it it one that will save multiple EditTexts where the user can enter stuff.Like say if it was a note app,how would i get them to save?
There are multiple ways to store data on Android. Read about data storage.
In your case you might have multiple text records with some metadata (time when created, etc..), so I'd recommend the database.
Check out how to store preferences with android's "SharedPreferences":
http://www.javacodegeeks.com/2011/01/android-quick-preferences-tutorial.html
This way you can indefinitely store whatever you're working with as a string, object, etc. Also, you can check out how to work with android's SQLite Database, which might be harder to figure out when you start working with it, but it gets easier over time.