I have an application which pulls its data from a local XML file. However, the data changes overtime and I am looking for a way to update it without updating the whole application.
My main goal is to create an update method which would connect to Internet if such connection is possible and update the application so that the next time the application is launched without Internet access it would display the latest version of data.
Since Android application files are in read only state I need some sort of workaround. I am thinking of two possible approaches. First one is to download an extra file and work with it, and the second is to utilize a SQLite database.
So my questions are:
Is it possible to create application with updatable information?
If so what is the right approach to accomplish this?
I think you should use a "Fridge".
When first launch, take default data and store it in sd card or internal storage, and replace these data when an update occurs.
Related
I need to clear all app data including cache without killing the application. All solutions I have seen either just remove cache data or they kill the application after removing app data. Is there any way to do aforementioned thing without the application being closed?
Android developers save user data mainly in three locations. File System DataBase SharedPreference.
File System
context.getCacheDir();
context.getFilesDir();
context.getExternalCacheDir();
context.getExternalFilesDir();
You can navigate the file system and delete the file you create.
Database
You can use context.deleteDatabase(String name); to delete the database you create.
SharedPreference
context.getSharedPreferences(String name, int mode).edit().clear(); will remove all values in the sharedpreference file.
Indeed, it's your responsibility to find all the files and directories your app creates. I think it's hard to do it exactly right.
And with the application running, it generates new files when you are cleaning the room. So the methods above can provide your user a way to minimize storage usage, but can not really completely remove all data.
I'm creating an app where it can have tons of messages (let's say around 10,000). The user can browse them, see, select, send (e.g., those apps that show quotes and allows to send to someone). What should be the best way to store these messages? In the strings.xml, or in my own xml file. The app should work offline, so I do not consider using any internet connection or remote database, or even SQLite (once the messages will come with the app when the user installs it). When the user executes the app for the first time, the idea is to get all these messages (from strings, or other xml) and create a SQLite database. Which suggestion do you have?
What should be the best way to store these messages?
SQLite.
once the messages will come with the app when the user installs it
Use SQLiteAssetHelper to ship a SQLite database with your app containing your quotes.
Bonus points for using FTS3 (or FTS4, depending on your minSdkVersion) for supporting full-text searching. :-)
Since it seems like you don't want to use a database, you can just make use of your strings.xml file and hardcode the quotes. Or like you said you could create your own xml. Whichever consumes less space on the user's device will be more preferable. Choice is yours...
I am currently developing a program in Java using NetBeans that manages expenses. In this program I used MySQL to store data. Now I want to ask that if I give the program to one of my friend, he would also have to install MySQL using the same password that I used. Is there a way in which he will not be required to install MySQL?
Now suppose if my friend already has MySQL, but with a different password. My program would not work in that case, and it would be hard to replace my password with his password in the code. Is there a way to make the program run on his PC?
Earlier once, I have used an Oxford dictionary program. That time I did not have Microsoft Access installed. When I installed Microsoft Access I came to know that all the words of the dictionary are stored in a Microsoft Access file. How can I do this? I.e. how can I use MySQL/Microsoft Access to store data without the need to install either of them?
You can use an in-memory database like H2 Database if you don't require a large amount of data
But I think you should make your db connection configurable by using a properties file
If you want everyone to be able to use the database, you need to run it on a server that people can access through the internet.
However if you don't care about them using the same database and just want them to use their own, you could for example create a small file named "config.ini" or something like that and put the login information (like the password) in there.
Then just read it in your code and use the info you read to log into your database.
That way, every new user will only have to change the config.ini file without ever having to touch the code.
The best solution in my opinion would be SQLite as it is light, and data can be stored locally in a desired location in a single file. H2 is more likely to be a developer tool.
This solution does not require additional software to be present on the user machine. Of course it has its limits, but as a simply storage for program dynamic data it is a good solution. It is worth mentioning that Android applications also can store their data in LiteSQL. It is a bit different approach there, but the principle stays the same.
I am trying to do an eclipse java android app using internal storage.
It is a notepad. What it should be able to do is write and save notes, search for them an edit them.
the most similar application of what I need is this:
http://developer.android.com/training/notepad/notepad-ex3.html
but I dont know how to modify if to use internal storage and not external, i also found this file that allows you to read and save in internal storage
http://www.androidaspect.com/2013/09/android-internal-storage-tutorial.html
but now i dont know how change the database for the inernal storage
Okay let's break it down. You want to make something that will let you take notes. Fair enough. You need the kind of storage that will make retrieval and insertion easier.
Let's start with a single text file that you store somewhere (internal or external). If you use this approach, inserting and deleting data becomes difficult because any changes will require you to make changes to the actual text. Not to mention, you will need to format your notes in a way so that you can differentiate one note from another.
Okay, so will using multiple text files solve this? In a way, yes, but you can go for a better approach using SQLite.
SQLiteDatabase has methods to create, delete, execute SQL commands,
and perform other common database management tasks.
SQLite seems like the prime candidate for your storage because it makes CRUD (Create, Read, Update, Delete) easier. Instead of trying to modify the code, start from scratch.
Have a look at this tutorial https://www.youtube.com/watch?v=j-IV87qQ00M
What is the best way to store a data set locally on a mobile device for further processing in Java?
The data set is going to be retrieved using SOAP and will consists of about 50 to 100 'objects'. Each object is like an email thread - main message followed by several updates (mainly text, occasionally graphics).
Expected actions on the 'objects':
read
add new update / send an update to the server
change status / send an update to the server
Is it better to operate directly on an xml file, implement a local data structure or perhaps use a database of some sort?
Target devices: Android & Blackberry. I would like to keep the solution as generic as possible to make it easier to reuse parts of the code the mentioned platforms.
Many thanks, Luke
It depends on you:
If you want something fast - use SQLite database or Store it in XMl File.
If you want something easy to implement (but slower) - use SharedPreferences
If you are thinking about to use SQlite or Xml file than i will suggest you to use SQlite database because you need to perform such operation on the data.so reading from xml file and again writing it to file will be little slower than SQLite database.
Hope this helps.