I am in the process of developing an android app, and I need a way for the user to enter a Name and then save this name to a .txt file in the SD card. When the user adds another name, this file should be modified to include that name. I was thinking of an array list, but I've been trying for some time on things to use but I'm not sure how. (I don't think an object output stream would work(?)). Also, I need the user to be able to read and access this file within the app.
Thanks in advance for the help.
Is there a certain reason why you are using a .txt file? I would suggest you use a SQLite database for this particular project.
EDIT: Here is the one of the best articles you can find on building SQLite in android.
Building a Database For Android
Related
I'm developing a simple note app, some kind of diary but I need a function where I click on the "attach" button so I could attach files from internal and external memory from the phone, the files would be pictures and maybe, if possible, video and wav files, all of them together with the text file on the note app, and I would need to save all this in a database, so I would like to know if that is possible and how do I do it , I read about sharing files from apps to apps on android developer site but I got confused, so I would like someone to help if possible, btw sorry for my bad English I'm not a native English speaker and it's my first time asking here, so I would be glad of somebody could help with this.
Hi Leonardo Medina Lango,
You do not need to save whole file in your app's folder. Save only file path to your sqlite database. If you that files in your cloud than sync sqlite database with your cloud server from background service.
I develop one application in android and i want to create a database on sdcard but i want to it secure that database file should not display in any file explorer. user should not get the location of database file.
In database, data is very important.
Please Help me.
Any thing on sdcard can be acessed by all application (unless you are using SecureElement)
In case you don't want other apps to access it simply encrypt it.
I want to use data from an xml file to populate AutoCompleteTextViews and MultiAutoCompleteTextViews, and I also want to be able to edit this file while the app is running so that the AutoCompleteTextViews can be updated with new information. What is the best way to go about this? I know that files in the /res folder cannot be written to during runtime, and writing to external storage is slower than accessing internal storage.
One way you could do this is by creating your own SQLite database.
I would make sure that the scope of what you are doing merits a database, though.
The other option is just to create a flat file with keyValuePairs and look up the value with the view's ID as the key. This could be stored in external storage. Access speed should not be a big concern for a text file.
I'm writing my first serious Android App, which basically is interface to three DB tables.
Data in those tables are predefined by me, so, user should install those app with those data.
What is the best way to include those data in application package? Maybe there is a way to embed SQLite into my application distribution?
Or is the only way is to define array of "insert into" strings somewhere in class and execute them to fill internal SQLite storage?
Would appreciate any recommendations.
I am currently doing the same thing in my app. Having a sqlite database file in my assets folder and copying it into the SD card at startup if it's not in there. There's a nice tutorial there and I use part of its code.
Put the database file in your assets and then copy it over to your application's data directory.
Your can check out this tutorial
I have created an android app that calculates the numerical values of word, and gives you a list of other words with the same numerical value. The way I have been doing it, is storring the words and value in a .properties file. Ie. A line from a .proprties file called "myWords" will have something like: 61=you, then I just use a get() method to call it,
ie. String myString = ResourseBundle.get("myWords").get("61"); would return the string "you". Is there a better way to do this? My guess is that this is not the proper use of a .properties file, and I was wondering if there was another way to do this correctly. I want to include the file in assets folder of the app, and from my limited understanding of sqlite, you can create a file within android, but you can't just include a file in the assets folder, and then read it. So that said, is there some other type of file that I should use, or was I wrong about sqlite, or is the .properties file being used correctly?
SQLite is your best bet and is the best way to handle your data on an Android phone, that is why Google bundled it on Android in the first place, to avoid people the pain of dealing with files.
If you follow this Tutorial they will show you how to create your database in your computer and then load it up on your "assets" folder and access it from your Android application.
Hope that helps!
You can use a csv file, read it from the assets folder each time the app starts or only once after installation and then store the values in a database.
Take a look at my answer here on how to read the files included in your app (you would use a csv file instead of a libray, but it's still reading files): Hosting an executable within Android application
Edit: here's another example to read from the assets folder: Image uploaded from the android app space seems corrupted
You can try out database option. Here is an interesting tutorial on how to pre-populate a database and then ship it out in the APK.