I want to save some information about users' accounts in an EditText/TextView inside the app. For example I want my app to save in the EditText/TextView the content "Admin" for admin users and "User" for simple users. But I do not want to access the database every time the user opens the app. How can I save the content of the EditText/TextView even if the user decides to exit the app?
The users will not see the EditText/TextView. It will just help me avoid some reads in the database.
Just save it local / cache the data on the users device.
https://developer.android.com/training/data-storage/app-specific
Related
I have an application where the user can add quotes.
I'm using Room for data storage.
I want to make it so that the user can add a quote and it would be visible to other users of the application.
Questions:
How can this be done correctly?
How to open access so that all users can see, not just you?
Thanks!
I'm currently working on an Firebase android application, and after doing some research it seems that Firebase doesn't allow apps to display user information other than the logged in user, for security reasons.
I would like to know then what are some secure ways to do so, or how is it usually done, because what is the point of having profile pictures and other information if you can't show them to other users anyway?
For example, should I save a profile picture copy on Firebase Storage for each user? How should I link the actual images to their corresponding user? What about other relevant information about the user, should I create a "User" node in firebase database that somehow links to the original user in "authentication"?
Should I save a profile picture copy on Firebase Storage for each user ? Yes
How should I link the actual images to their corresponding user ? You can create a folder Users and then for each user create a folder with their userid that uniquely identifies each user. In other words, you can create a Firebase storage structure like this :
Users
|_userid
|_picture
Should I create a "User" node in firebase database that somehow links to the original user in "authentication"? Of course if you want to store and get user's information. Just avoid to store passwords and emails.
I am stuck at a point and can't figure it out how can I manage to send user's data which is stored in the database to another user with admin privileges after user just press a button in an app and display this info on admin's screen.
Till now I am done with the database to store user info during registration, I am new to android development and have just basic knowledge is there any better way in which i can possibly do that please let me know.
thanks
Yes, I assume you access your SQLite with a content provider/resolvers. You have to make them available to other apps, at which point they can access your data. Starting reading about it here:
https://developer.android.com/guide/topics/providers/content-providers.html
Think about why you can easily use content provider/resolver to see all gallery photos, it works the same way. It is because the photos are stored in a publicly available SQLite database and by using content provider you can access or even modify them.
I'm currently making an offline application for android. Is it possible to have two types of users - admin and nonAdmin? The admin is the one who will add data to the application while the nonAdmin will just view data from the application.
If it is possible, how can I update the data of the nonAdmin if the admin had added new data to the application?
Sure, this is possible. What kind of data do you want to add?
To get started use two buttons "Admin" and "User" in your first view which is shown when the application is started.
"Admin" starts the AdminActivity to add data. This could be stored in Key-Value pairs, an SQLiteDatabase or directly to the internal storage - depending on what kind of data you want to add.
"User" starts a read-only perspective of your application, showing the data added by the admin.
I have an app which links to an dropbox account. I am able to login once and is saves that. But each time it asks whether I want to allow access to the app or not . Is there a way to save this preference as well and provide access to the app permanently ?
Read again https://www.dropbox.com/developers/start/authentication#android especially "Return to your app after user authorization".
After successful .getSession().finishAuthentication() there is AccessTokenPair tokens = mDBApi.getSession().getAccessTokenPair() which will give You data, which You should save somewhere for later use (You can use SharedPreferences for this).
In start time of application You have to check existance of this saved data, and if it's there, You don't have to call .startAuthentication() again, instead You should call .setAccessTokenPair(access) with saved data as access (look at top of https://www.dropbox.com/developers/start/files#android ).