How do the Note Apps create and save a note you wrote - android

I am working on an app and I basically want to implement some type of function like the note apps do. Basically I have a listview set up that has a link to different xml files. I want the user to have a create new option where they can add some text to an edit text and be able to save the text and add it to the listview I have set up.
My question is how do apps like the Note Pads and Memos ect. do this. Do I need to set up some type of database or?
I have googled it quickly and did a quick search on stack but I don't know if I'm even searching for the right thing. I am just looking for a step in the right direction please!
Thanks!

They all save their data in a database. For android you should use an SQLite database because it is included in the SDK. There are a lot of great tutorials for SQLite out there, but I think that this is the best one
http://www.vogella.com/articles/AndroidSQLite/article.html
It is possible to do this using SharedPrefernces, but I would not recommend it, for efficiency and simplicity

Related

SQLITE DATABASE for multiple access

I would like to ask if any of you out there uses android studio and sqlite for apps that require multiple users to access the database? I have been looking for source codes and examples online, but haven't seen any. I understand that other database might be better but I only have enough time to use sqlite as I am alr using it now. Could anyone help me with example source codes?
viewComment.setText(name+comment);
replace with below code
viewComment.append("\n"+name+comment);
Update -
limit number comments - use counter , after certain number of hits stop appending to text view.
U can make scrollable too.
for above both please check your requirements or UI/UX teams.
You will have to work with RecyclerView here. Add a different layout resource file in your layout folder and bind it to the RecyclerView and all your comments must be stored somewhere, like in a database. You will then achieve your desired structure.

What is the best way to save all high-scores of multiple levels in android?

I am writing a minesweeper application in android. It's got 3 difficulty modes and I want to save all the scores of all three difficulty modes. If I wanted to store just the high scores for all the modes, I could have done it with a SharedPreferences object but I want to store all the scores and display them to the player sorted by the time taken to solve or date on which it is solved.
I have thought of saving data in a file, or in a json file. I don't want to use SQLite databases because it's too much code.
I simply want to know if there is a better way to do this other than saving everything in a file (maybe in the assets).
There is a similar question but I don't think the accepted solution can be used to solve my problem.
You can use Firebase Database for that. The good thing with the database is that if you want your game to also display the leaderboards to others who are playing it, it shows in real-time. Simply add data when the game ends and filter the results based on the data. Hope this helped, heres a link to get you started here

Efficient ways to search for text in an android app

Say, I have a 100 text files (100kB each) and I'm interested in searching those files for strings/keywords entered by the user.
One way to do this would be to read them every single time and look for the entered string/keywords and I could implement that but it might be inefficient.
Since I know all the data before hand, are there any other better ways to do this?
See example on google devs:
http://developer.android.com/training/search/search.html
They use memory only SQLite database with FTS table. But you could easily change this to persistent db (drop VIRTUAL when creating table).
Press Ctrl+H . It will open search menu. Go to File Search and tick mark the things as per your need and the text which you want to search, write it into the containing text: portion. It will search for your text in the whole project.

Do I need to use PreferenceActivity or database or another?

Someone know here, I'm a newbie for android development. Now I'm trying to create a simple fitness application. The first thing is my app will do is getting some data from user. For example; weight, height, age etc. And Program will return something that can change by data what we got from user. I wonder, how do need I storage the data? Need I use PreferenceActivity, database or another?
Also I want to ask, do we need to use term of preference as suffix for layout elements when create layout to use for PreferenceActivity?
How many users do you support in your app on one device? If just one, go for shared preferences: it's easy to use and you store very little data.
If you support multiple users, you may start thinking about a SQLite database. Also, think whether you want to expand your app in the future and maybe add some fitness goals, track weight progress over time, etc. In this case, you may want to use a database as it is much easier to expand.
As for your second question, if you use PreferenceActivity, you don't need a layout at all. You define all preferences in xml file. Check this link for more info: http://developer.android.com/guide/topics/ui/settings.html
Just take sharedPreferences for this little amount of data
If you need to save only that kind of data I suggest you to use sharedPreference (here a nice tutorial http://www.vogella.com/articles/AndroidFileBasedPersistence/article.html).
Then, if you need to save some history, I suggest you to create a database, Android use SQlite (http://www.vogella.com/articles/AndroidSQLite/article.html).
No, you don't need to use your preference name as a suffix for layout elements, but could be useful for you to use similar name.

Android Database

I am new to android. I am creating ToDoTasks application in android. i have crated Gui of the application and it is working perfectly. I am able to add tasks in it. Now i want to know that i want to save 'task list' in an area so that every time user comes on it , than it should maintain the list of previous tasks which were added in it. What is the best way to do this ?
Whether i should go for database in android or is there any other way to do this ?
Please suggest me. Please don't mind , i know this is a silly question but i have no other way to solve it.....
You have multiple options with varying degree of complexity.
Do you foresee sharing your todolist with another application. If yes then you need to host your data as a content provider.But I digress.
The most simplest option is Shared Preferences. The api is very simple to use and you do not need to write a whole lot of plumbing code. You can directly store an list of string in the shared preference of your activity.
The more elaborate solution is using sqllite. If you foresee your domain model to become more complex than just a list of strings, then you should see if the additional complexity is worth it.
Look here for more details. (I will not worry about the file options, the other two mentioned here are superior to that solution)
You can use sqlLite db for android. See this or this for example.
Here is another example of an SQLite implementation:
http://p-xr.com/android-tutorial-simple-but-persistent-data-storage/

Categories

Resources