I want to be able to prompt the users to enter the details required for the app only when it starts up for the first time (not other times). These details will be held in a database on the phone.
Would it be better to check the database each time or put these details in a shared preference? Furthermore, is this type of activity even possible on Android?
Depends on the details really. If it is a large amount of information you might consider using a Database. For just basic identification information, SharedPreferences should be fine.
If you do use a Database, you might consider loading them into your Application object. This would depend on how frequently you use this information in your app.
To check for the first start of the app, a SharedPreference is generally used AFAIK.
Use SharedPreferences or Database depending on the data complexity and its need later on..
Store a Flag in SharedPreferences and set this when user enters the data.
Check that shared preferences flag while on your first activity and redirects accordingly(to Details/one time page) if required.
here even if a user manually deletes data using Settings > Manage app > your app > clear data, Your app will know to get the details then from user....
Related
I am new to this site so I am sorry if there are any inaccuracies in this question. I am trying to create a login system using a local database. Previously I did some research on how to make a login system but still have no luck. I am using something like intent.putExtras() (sorry, not sure what the correct word for that is) to store user's details such as username, date of birth etc, so the following activity can receive the data from the previous activity. However, I just figured out that SharedPreferences is used by many people to implement a login system and I am planning on using it as I have an impression that it is more reliable (correct me if I am wrong). However, I have been implementing a login system using intent.putExtras() and never seen anyone implementing a login system that way. To make sure my current way of implementation is reliable, my question is, can I use intent.putExtras() instead of using SharedPreferences?
intent.putExtras(//something) only stores data in Bundle temporarily. You need to store the user info (or if user has logged in) somewhere, to be accessed next time you open the application.
intent.putExtras() are intended to be used, for example, when you want to pass data from one Activity to another.
Locally, sqlite and shared preferences are your only options.
My question is, can I use "intent.putExtras(//something)" instead of using SharedPreferences?
With what you want to achieve, no you can't.
After you edited your question:
If you only want to pass data then you can do so with intent.putExtras(), if you want to store data locally, then you will have to use sqlite or shared preferences.
Simple question but something I haven't been able to wrap my head around.
Can I run a query in such a way that I can tell if this is the user's first time using the app, using information from Parse.com's InstallationQuery method?
Don't know about parse, but you can do this with shared preference in android
Shared preference will not be created a variable first time and set it to true during first load of app, and for subsequent load it can be set to false.
http://developer.android.com/training/basics/data-storage/shared-preferences.html
Next time when you uninstall the app, shared preference are automatically deleted.
I am working on application, my requirements is when i post data as parameters like ID, Value etc using rest webservice and than i get some data as a response like deviceID, VendorID, driverID.
MY application senerio is. when user first time install app he/she can see the screen that enter the above data like ID, Value etc and some response appears that response is basically user configuration like deviceID, VendorID, driverID and has to save. And and than automatically move to the next screen using intent.
Now when user close app and than again open he/she will automatically move to list screen if he/she is login other wise stay on login. NO configuration screen at the, because its setting first time save in app (deviceID, VendorID, driverID).
How to save that configuration data of user first, which one is the best way.
Please give me best solution like in tutorial form and also little bit explenation.
Thanks
It depends a lot on what the "some response" is and how much data do you want to store.
In Android Storage Options:
http://developer.android.com/guide/topics/data/data-storage.html
There's Shared Preferences:
http://developer.android.com/reference/android/content/SharedPreferences.html
http://www.vogella.com/tutorials/AndroidFileBasedPersistence/article.html
How to use SharedPreferences in Android to store, fetch and edit values
Maintaining a database seems to be an optimal way.
You can store, update or over-write the data according to your need. The Id's can be maintained in tables, and further info with each Id can be associated in rows, increasing attributes and relating it with keys.
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
http://www.vogella.com/tutorials/AndroidSQLite/article.html
http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/
I have to store value for temporary use so I used SharedPrefences for that but in this case when the user goes to Setting -> Application -> Application and then clicks on Force stop and Clear data then SharedPrefences is lost. So is there any suggest to solve this problem?
You can use element android:manageSpaceActivity in your AndroidManifest.xml to point to an activity. So when the user goes to the details page of your app in Settings, there will be a button Manage space instead of Clear data. Clicking that button will bring your specified activity up. Then you can show the user options to manage data (database, preferences…).
The only work around to fix this problem is to use a web service and store your data on the server. You can make device IMEI as primary key to avoid duplication.
as already mentioned above, the only proper way to prevent the user from having the possibility to delete your app data is storing the data on the web and download when needed. You can do both and then perform a check on runtime. If the required data is missing, then it gets downloaded
I understand how to create a one time activity that saves to preferences to make the activity appear only once. But can someone show me how to save the "first open" screen to sqlite. I want to prevent users from clearing the data and seeing the screen again.
to clarify
I am looking at a password login tutorial and i want the users to register a password with the app but once the password is set, I want the registration screen removed for security purposes. Can someone please help.
Thanks
Using SQLite as your storage is not going to help.
Android will store your database under /data/data/your.package.name/databases/yourfilename and thus, when a user clears the data for an app, it will remove any databases, along with shared preferences too.