How do I save read-only data? Should I use Sqlite in this case?

Asked

Viewed 130 times

4

I’m developing an app (a widget actually) that shows some sentences in home user. I have about 1000 sentences of approximately 150 characters, how will I store it? In this case the use of DB is worth it?

1 answer

8


It has several forms that can be used and in this case virtually any solution is feasible. You have not given more details or requirements, it is not easy to answer this mainly without incurring opinions that do not help at all.

Sqlite

So trying to be objective I say I would use the Sqlite yes. No because it is the best solution, I do not know if it would be in this case. But because it works well today and will probably work well in the future and because there is probably no contraindicator to avoid Sqlite.

Of course if your requirement is to have something very small, you need to save every byte, I would avoid the database. But it consumes very little memory, it is rarely important to have that saving.

Raw file

Maybe I don’t even need it, maybe a more basic file will be enough. Manipulating a raw file may seem very simple but can also bring unexpected complications mainly if you want to evolve the application in the future. Creating a format can become complicated and incredible as it may seem even if the format is as simple as having lines (simpler than the CSV format) if you are familiar with databases and not with file manipulation, the easiest is what you already know. One of the reasons Sqlite was created is so people don’t have to deal with raw files.

List of internal data in the application

And if the app data is never updated without the app being updated, it might even be the case to list the phrases in the app. But I wouldn’t think of it even if the idea is this because you might change your mind in the future (if you make an abstraction it might be a good idea to start).

Completion

First choose the easy, powerful and flexible then you think if you need to optimize. Sqlite seems to be a cannon to kill bird. But I’m not seeing any real disadvantage in using that cannon.

Apart from these important remarks, only you can say whether it’s worth it or not.

  • In fact the application is extremely simple, it just draws an id and puts it on the user screen and after 10 minutes does it again. I think that for educational purposes working with Sqlite will be a good one, besides that I’m thinking of making a new version in the future. Thank you.

  • Marcelo, you can also use Sharedpreferences.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.