How to auto save Id(unique no) retrieved from database, in android - android

I am currently working on a android application, where I want to save the login details. I am using a unique id (primary key auto increment in mysql table) to uniquely retrieve the details from the table. I am using this id has a login attribute. How to make it as auto login or, when the user enters the login page, the id should be already present?

You can use SQLITE DB for this. When user login than data will be save in SQLITE DB. Sorry I couldn't comment. I have low reputation..

Related

How to cout the number of SQLite databases in my app?

Is there a way of count the number of SQLite Databases in my app without the need of inform their names? I need to make the following thest:
If there is one or more Databases in the app, I want to direct the user to the login screen, if not, send him to a sync screen where he informs some personal data and the database is downloaded from my webservice.
Ps: The app is a remote version of a web based system, and unfortanatly it needs to have one database per user and it's name isn't the same for everyone.
After the answers I've decided to create a standard database saving the user ID and name, so if it's empty the app opens the login screen, if not it opens the sync screen.

Android SQLite Databases (Explain Like I'm Five)

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.

android SQLite - manage a single database with multiple users

I'm creating an app which allows a user to login and retrieve some information about his account from a server. These information are inserted in a SQLite database, and then the user can set other preferences on them (I use sharedpreferences for this).
Now i want to expand the app allowing more users to login.
The problem is that i don't know exactly how to manage the database with multiple users, infact:
if I keep db after logout, and login with another account, I find the information related to the previous user;
if I don't keep the db, and erase it after logout, I miss all the preferences set by the user;
How can I solve this problem? Thanks..
This can be done in multiple ways
1. Have user id table created and link that to other tables using foreign key.
another way is
2. create new DB for each of the users. so your database name will have username. If user name changes then database changes.
with second way your code changes will be minimal.

Simple MySQL database questions - Database per user of application?

Currently I have developed an android application that uses a local sqlite database per installation. The database comes pre-populated with static tables, and the entire point of the application is to allow the user to assign dates/comments with the pre-populated information in each table.
I am looking to bring this online, and move the database to a mysql format, allowing access via desktops and other mobile devices. Is the best way to handle this to assign each new user a new database?
I would strongly avoid creating multiple databases, and instead add relationships to the existing database structure you have with a users table. Each user has an association to each existing object. Keep in mind sharing with other users in the event that you may want to allow one user to see another user's info.
My suggestion is provide an update to the app where after the first launch after updating it pushes their information to your MySQL database and inform the users that they can access their data via other methods now.
how many user to you expect? I would use only one database with a user table instead of hundreds/thousands of databases.
One table for all users (only with user info like id, email, password, etc).
Another table with comments (with user id and his comment), so that you can add as many comments per user as needed. If dates are related to comments put them on this table, else another table for dates as well.

Creating Unique User ID

I am currently using PHPmyadmin to store data in my mySQL database. The android application I am developing requires the user to select some data and this data along with its attributes need to be stored in my mySQL database. I know I have to create a unique table for every user who downloads my application but how do I go about doing this without having access to the program which the user downloads ?
For eg: let us say there are two phones which download my application. I would want to create two tables in my database which the particular phone knows and can access
Creating one table for every user is a terrible approach. Instead you should create a users table, with a unique ID set to auto_increment, to generate those unique IDs. Then use separate tables to store the data you might need, referencing the user ID from the users table.
It might sound a little confusing, but there are lots of good reads about this on the Internet.
You can generate unique user id in php using uniqid(”, true) function.

Categories

Resources