DB Schema SQLite Android - How do you control what data users see? - android

I'm trying to learn the best way to control the data a user sees within an application.
As an example I've set up a database that has a table for a bunch of parks that each have separate fields
DBSchema
Now I will have multiple users using this application
I don't want them to be able to see all of the parks available
I will manually create users and select which fields they see, this
will be the only way to get an account.
What is best practice when dealing with this situation? How should I set up the users table in the database in a way I can control what parks are visible to them?
I am currently exploring some possible solutions
Send a pre packaged SQLite DB with the application, and use HTTP Post
calls to alter the DB depending on which user signs in.
Store the entire SQLite DB on the server and make a call to it when a user first signs in.
I am somewhat stuck with my development at the moment because I don't know how to handle this.
The applications functionality is complete in its current state, having multiple users see something different from the same database is something I have never done and should really know.
Any tips on what I should be researching or general guidelines for this would be great.

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

What is the best way to store MySQL database for Android apps

I know this is not a type of question that should be asked on this platform, but I really need an good insight from the people who have worked in this field. I want to set up a database for my Android app. My app has no Image or Media data, it's all text for now, like user posts, likes and dislikes. I am thinking of storing all this in SQL tables. I want to perform tasks like auto deletion of entries after a certain time they have been entered. Store likes and dislikes, deletion of posts based on their dislikes, (if dislikes cross certain threshold, I want the post to be deleted.) I was thinking of using PHP and use hosting from a basic hosting provider like, hostgator or something like that. Though I am worried about the performance. For now I don't expect large no of users, only few hundred a day. But they will be interacting with the database all the time for eg, liking a post, disliking a post etc. It would be really nice if someone could guide me into right path. Thanks!!
You need to develop web services for doing that.According to me rest api is best for the task you wanna do.
check the link for demo.
http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/
You could use the inbuilt SQLite database which is standard in android development or you store them in a backend on your server on a MySQL instance and the app can access your data over a restful webservice.

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.

What would I need to do in order to connect to a central database with Android?

I'm about to build a GPS Spot Finder application with Android and I am trying to decide what requirements are feasible and what aren't. The app would enable users to essentially add different spots on a Google Map. One of the problems would be fetching the data, adding new spots, etc, etc. This, of course would mean the database would have to be online and it would have to be central. My question is, what kind technologies would I need to make this happen? I am mostly familiar with XAMPP, PHPMyAdmin and the like. Can I just use that and connect Android to the database? I assume I would not need to create a website...just the database?
What different approaches can I take with this? Be great if people can point me in the right direction.
Sorry if I don't make any sense and if this type of question is inappropriate for Stackoverflow :S
Create a website to access the database locally, and have Android send requests to the website.
If users are adding spots to a map that only they see, then it makes sense to keep the data local to Android using a built-in database (SQLite). That looks like
ANDROID -> DATABASE
You can read up about SQLite options here.
If users need to see all the spots added by all other users, or even a subset of spots added by users, then you need a web service to handle queries to the database: Connect to a remote database...online database
ANDROID -> HTTP -> APPLICATION SERVER -> DATABASE
Not only is trying to interface directly to a database less stable, but it may pose risks in terms of security and accessibility.
Never never use a database driver across an Internet connection, for any database, for any platform, for any client, anywhere. That goes double for mobile. Database drivers are designed for LAN operations and are not designed for flaky/intermittent connections or high latency.
Additionally, Android does not come with built in clients to access databases such as MySQL. So while it may seem like more work to run a web service somewhere, you will actually be way better off than trying to do things directly with a database. Here is a tutorial showing how to interface these two.
There is a hidden benefit to using html routes. You will need a programming mindset to think through what type of data is being sent in the POST and what is being retrieved in the GET. This alone will improve your application architecture and results.
Why not try using something that is already built into android like SQLite? Save the coordinates of these "spots" into a database through there. This way, everything is local, and should be speedy. Unless, one of your features is to share spots with other users? You can still send these "spots" through different methods other than having a central database.
And yes, you just need an open database, not a website, exactly. You could technically host a database from your home computer, but I do not suggest it.
If you are looking at storing the data in your users mobile nothing better than built in SQLLite.
If you are looking at centralized database to store information, Parse.com is a easy and better way to store your user application data in centralized repository.
Parse.com is not exactly a SQL based database, However you can create table , insert / update and retrieve rows from android.
Best part is it is free upto 1GB. They claim 400,000 apps are built on Parse.com. I have used few of my application typically for user management worked great for me.

Categories

Resources