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

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.

Related

SQLite DB problem when we use different accounts in single app with same device

It's not a code problem but it's just by my curiosity.
I am making an application that can be logged in by social login, and also email login.
In my application, I plan to use some SQLiteDatabase to save simple datas.
However, when I just save it with A account and login with different account, won't there be conflict because its the same device and server is not intervened with it? How do you know it's different account when its the same device, one application?
Think its sort of a silly question maybe, but if there's a way that everyone uses to solve it, I would like to know.
There can be two cases -
You want to use same database for different users -
In this case, there is no problem as your SQLite database gets saved in your app's /data/data folder which will be always accessible from inside your app.
You want to use different database for different users -
In this case, you have to add user_id column in all the tables of your SQLite database, and based on your user_ids, you can do your database actions like query, deletion, etc

Does SQLite Store Data from all Phones in a Single Database or does each Android Phone Read from a Different DB?

I'm a little confused as to how SQLite works in Android development. I know it can be used to store data but is this internal data only? It will write to a .db file on the phone which is just a test file. But say I insert a few records on my phone. When a different user logs in and views the database will they see the records I just inserted or are those records only going to display on my phone? If it's the latter what's the best way to have all the data be stored in a single database so all users can add / delete from the same pool of records? Would it be a web service callout to a cloud db like MySQL?
Also, extra credit question: if I'm making an iOS app that will need to read from the same database as the android app should I even consider SQLite or should I use something else?
I know it can be used to store data but is this internal data only?
Yes, if I understand what you mean by "internal data".
When a different user logs in and views the database will they see the records I just inserted or are those records only going to display on my phone?
Well, that depends entirely on what you mean by "logs in".
If you mean "a different user uses my phone, just by swiping to unlock", the phone cannot tell you apart from this other person, and therefore that user sees the same data that you do.
If you mean "a different user uses my phone, but I set up two user accounts on the phone, and that user has logged into my guest account", then that user will get a separate database (and separate everything: apps, etc.).
If you mean "a different user uses their phone, but uses the same app", then that user will get a separate database, because it is a separate device. This is not significantly different than the user having different word processing files on their computer compared to your computer.
From the standpoint of the Android SDK, the SQLite database is a file on the device.
If it's the latter what's the best way to have all the data be stored in a single database so all users can add / delete from the same pool of records? Would it be a web service callout to a cloud db like MySQL?
I would not consider MySQL to be a "cloud db", but, yes, your app could communicate with a Web service that stores its data in its own central database.

Android-How can i attach SQLite database in python app

So i am writing a python3 app with kivy and i want to have some data stored in a database using sqlite.
The user needs to have access to that data from the first time he opens the app
Is there a way to possibly make it so that when i launch the app, the user that downloads it, will already have the data i stored, like distribute the database along with the app? so that i don't have to create it for every user.
I have searched here and there but haven't found an answer yet
Thank you in advance
Just include the database file in the apk, as you would any other file.

Database Structure Differences between Web & Mobile Development

I would like to know the difference between the structure of database on mobile (Eg; SQLite) and the structure of database on web.
For example, on mobile app development, the database table related to
user will only have one row. But, in web (back-end), there would be
many row for user table. So, even though we only have one row, we
still keep creating the user table in SQLite ?
In my App, all the data are coming from Web Services. And I would like to support full offline support. So, it is like i need to create SQLite structure and tables for everything I received from web services.
The other data are making sense. But, for user, there gotta be some
logic in here to for that specifically. I need to store every data I
am storing in my web-services. But, still, it feels wrong to create a
user table which will only have one row in any given situation.
Let's say in Facebook App. News Feeds are storing in database table. But, how they store the logged in user info for offline ? By creating a user table with only one row ?
NO, If I was to do something like that, then the db on the app would be quite different from what is on the server.Things to consider:
On server your user db stores many different users details like name, age, location, phone number etc. While on app you really don't need all the users, but just the current user's details.
If it was something like facebook then On server I would have users tables, photos, friends, posts, etc. On server all the users posts, comments, photos would be saved BUT on the apps end I would only have the currently logged in user details. The tables doesn't need to be the same, you could have less tables on the app.

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.

Categories

Resources