Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Tom Finet
Tom Finet
7,027 Points

What is the best way to develop a login and sign up system in android?

I am developing my own android application which requires users signing up, logging in and logging out. I would like to know if this can be done with a SQLite database and what is the best way to implement logging in and out. How do the big android app development companies manage logins and how should I?

Thanks a bunch!

1 Answer

faraz
PLUS
faraz
Courses Plus Student 21,474 Points

Sarah,

SQLite is used for local data persistence, it can be used for user authentication, but it would only allow users to login and signup on that specific device, since it wouldn't be synced with the cloud. I strongly recommend using Firebase for implementing your own login and signup system in Android. Firebase is a BaaS (Backend as a Service) provider which means that they make it easy for developers to link their applications with cloud storage, abstracting away all the maintenance and setup work needed for having your own database in the cloud.. They provide you with an easy to use Android SDK for storing user data in the cloud, and have step-by-step tutorials on how to implement sign up and user sessions in your app. If this was a month ago, I would recommend Parse as there is a tutorial on here that use it, but unfortunately Parse has shut down and is no longer accepting new user signups. I believe that Team Treehouse will be making a course which uses some kind of BaaS provider in the near future, I'll send them an email and update my answer here when I get a response!

Hope that helps, good luck! :)

Faraz

Tom Finet
Tom Finet
7,027 Points

Faraz you legend! Thank you for the help, plus isn't it more secure to store it on the cloud. Ohh yeah, I have got to add a password encryption system. Does Firebase do this for me. In addition, I am wandering how the giant app companies manage user authentication; do they use there own huge database and how scalable is Firebase? Also how do I add user authentication which includes an email, username, password and payment methods with Firebase as looking through the tutorials it only shows me how to sign up using password and email?

faraz
faraz
Courses Plus Student 21,474 Points

Sarah,

Aw, thanks you! Yes it is more secure to store on the cloud if you are using a known BaaS (such as Firebase). You don't need to add a password encryption system, Firebase is owned by Google and passwords are encrypted with BCrypt. In terms of scalability, BaaS can get pretty expensive for scaling -- if you want a highly scalable system I would suggest hosting something yourself using AWS (Amazon Web Services), although that would require a lot more maintenance and setup. Giant companies usually have their own infrastructure, and startups usually use AWS, as it's super easy to scale effectively on it.

For payment, I would suggest looking into a payment API such as Braintree -- it's used by top companies like Uber and Airbnb or you can use the Google in-app purchases (IAP) API for integrating payments.

I would suggest sending email as a parameter in the registration request, then having the user go to a screen which asks them to pay, and not be able to continue to the next screen without paying. Then, after paying, you can have the app send a unique identifying token to the server showing that they paid, and have the make a payment screen no longer show up on the app after the app checks with the database as to whether or not a user has already paid. That's just a suggestion, there are many ways to go about doing this.

I hope my answer satisfied your questions, good luck! :)

Faraz

Edit (unix time 1454858161): Added BCrypt reference

Tom Finet
Tom Finet
7,027 Points

Ok, I understand, so for a 15 year old indie developer, what would you recommend? Using Firebase for my app because it is easy and secure, or use amazon web services. Is it challenging to get started with amazon web services? Does it cost a lot of money? I feel like Firebase is a little limiting for an app with the free account. I found this tutorial and since you sound pro, could you confirm that its not bs. Thanks dude.

faraz
faraz
Courses Plus Student 21,474 Points

Hi Sarah,

Congratulations on starting to learn coding at 15, that's great! I'm only 18 myself. :) I suggest you stick to Firebase, it's much easier to work with. AWS is free for a year and doesn't cost much after that, but Firebase is completely free. Firebase also has helpful guides on how to use it as well.

However, if you are really into databases and want to learn how to use them, as well as learn more about how to setup your own server and build a full application on your own (backend and app) I would suggest you try out AWS for a year with a free BaaS (BaasBox, Parse, Backendless) on your own server. Both Backendless and Parse have instructions on how to deploy on your own server, although it may be a bit difficult for someone starting out. After deploying and hardening (securing) your server, there isn't much else to it, you'll be able to setup scaling through AWS and have as many apps as you want communicating with your database.

Both have their pros and cons (ease of use vs. scalability with learning curve). The decision is entirely up to you. :)

Let me know if you have any more questions, Sarah! I would love to help you make your decision in any way I can.

Faraz

Tom Finet
Tom Finet
7,027 Points

Faraz you truly are a beast! I really like the idea of having all the code 'home made' If I were to go for the AWS option, what exactly would this entail? Would I have to learn a new language? In financial terms would it cost a large amount?

I see the point of going for the Firebase option, its easy and effective, especially for a beginner. But if my app takes off, I should definitely switch to the AWS option or even set the whole backend up myself, right?

The learning curve is probably going to be challenging and I am worried that I will be forced into building the server, instead of developing my actual app and focusing on the user. So, for a beginner I am going to stick with Firebase. Most likely later on I will transfer to AWS for scalability. Is this transition difficult? Will I need a team?

I am also going to take computer science next year and there is a database option so I could save the AWS for then. What do you think about my decision?

P.S: Would you be willing to share your email address so that I can consult you later, perhaps when building my home made backend.

Thanks Faraz, really appreciated.

Tom Finet
Tom Finet
7,027 Points

Ohhh... and what do you think of this tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

By the way I understand if you don't want to share your email cause you also have a life.

Goodbye

faraz
faraz
Courses Plus Student 21,474 Points

Is homemade better?

My word may be kind of bias as I manage my own server for my blogging platform, www.goblog.pw

I absolutely love working on my server. It's fun and although it usually requires a lot of tinkering to do things, I love that I have the freedom to setup whatever I want on it. I have tons of things I fill it up with, lol. If you're familiar with the Linux command line (this is super important), I would suggest that you try it out. AWS doesn't cost much

However, if you decide to start with Firebase and your app takes off (likely given your dedication), you can switch to the $49/month plan on Firebase -- it is possible to scale with Firebase, it's just that in the long run you would be paying less if you were scaling with AWS. I would go with Firebase for now and cross that road when you get to it, unless you are interested in experimenting with setting up your own server, in which case I would suggest you try out the AWS 1 year free plan. If it's too confusing after a few days of trying it out, you can always switch to Firebase. :)

Nothing is impossible with enough dedication and passion, which I see you have...however getting the data off would be difficult unless you switched to the $149/month plan which has private backups https://www.firebase.com/blog/2015-03-05-private-backups-for-firebase-data.html and even with that you would have to setup your own database and import the data into it... I would imagine it being pretty hard.

If you end up going with AWS, I wouldn't suggest doing it completely on your own from scratch (like the tutorial you linked to), there are many open source BaaS platforms which you can setup on your own server, instead of designing your own API which is harder.

The decision is yours. :)

My life is coding and spending time with my cat, lol. I'd love to stay in touch and help you in any way I can.

Shoot me an email: faraz@linux.com

Faraz

Tom Finet
Tom Finet
7,027 Points

Ok, I've made my mind up. I'm going to build my own server because it sounds awesome. It may be hard but it'll work out. What hardware will I need to buy? There is a course on Udacity which looks really good for configuring linux servers. https://www.udacity.com//course/viewer#!/c-ud299

What do you think?

faraz
faraz
Courses Plus Student 21,474 Points

Hey Sarah,

This comment thread is getting long and open ended. Send me an email, I'll reply to you on there. :)

Faraz