How to list my app downloads - android

I'm working on books library in my android app... so I want to add a functionality that allows the user to view the books that he/she has downloaded by my app..
any idea or hint to work this out?

The final solution depends a bit on the details you want to store for the books. If you only want to store the book title and author and you don't want to deal with a database yet then SharedPreferences might be an option. But they are more like Java Properties files and with this said not a good solution for persisting more complex data structures.
If you want to store more metadata of the books (e.g. the current read position, bookmarks, etc.) then you will need a database sooner or later. I recommend thinking about the data model first and then start with the SQLite database included in Android.
You can find more details here Android Developers - Data Storage

One of the way to keep track is whenever a book is downloaded store the required data in database and retrive it whenever required or delete it from database if no required in future.
Try this way.

If your app has already downloaded books, then you need a ListView to display them.
If, however, the problem is both in saving and listing, you should read the dev guide, esp about using File and getExternalFileDir.

Related

How to make MCQ test functionality that loads data from server

I am working on learning application. I want to add MCQ test functionality in my app. I want to load data from the server when the test started. and it will not call to the server for each question because it will slow down test process. I want to load all the question when the test starts and a new question will appear only when clicking on next question button. There will be four option in each question so at the end I want to send data to the server to verify the answer. I actually confused in what should I used to save question in internal memory. and then their answer to submit to the server.
Android developer guide has an explanatory list of available options for storage that you can leverage. Since you would want to keep this information secure. I suggest you should use one from the list below
Internal file storage: Store app-private files on the device file
system.
Databases: Store structured data in a private database.
Although a lot depends on the size of data and other specifics of your use case.
Based on the discussion in the comments. Here is a cool answer to the same, i.e serialize/deserialize the objects.

Should I use array or database

I am writing an app that contains a list of items with their information. When the users open the app, they would see the list, and when they select a particular item, they would get all the information about that item.
Right now my approach is I store the data in a multidimensional array in the java source file. When I push a new update, I might add new items in the java source file (so the array gets bigger). I wonder if this is the best approach. I tried looking up relevant information about array and database on the Internet, but I can't seem to find the information I need. Any advice for me?
Also, if in the future, I create a function for users to add their own items to the list, what's the impact?
If the user should be able to update it, if you should be able to update it dynamically (for instance update from internet), then the database is a must.
If that data is static and won't change unless you update the app, you can store it in the code or better, in a file (you can store in JSON format for ease of reading & parsing)
If use array, the newly added items by the user will be gone when the app restarts.
You can use a SQLite database stored directly on your phone (sd card for example).
An analysis of the storage options and what they're commonly used for can be found here. Personally I suggest SQLite database.
The database is good for permanent data, but realize it can create a bottleneck if writing to disk is not really necessary.
I am in the middle of refactoring an App to no longer use SQLite. I was inserting large amounts(10,000-100,000) of new rows at once, and it looked like it was going to take an hour based on my log feedback of the status. When I keep it in memory, it all loaded in about 5 seconds.

Data Storage - which approach for a song-lyrics-app?

I want to write an android app that basically shows titles of songs in a list view, and by selecting one song in the list, the lyrics of that sing are shown in a textview. In a second step there would be maybe a translation of the lyrics for every song.
So far nothing too complicated, but since I'm completely new to android programming, I wonder what's the best approach to store the data (i.e. the song titles/lyrics). I thought about a single (xml?)-file for each song where the filename is the title and the file contains the lyrics. I think that would make it easy to add new songs. where would such files be stored typically? /res/xml?
Or would another approach be more suitable? database storage? content provider?
I would use a database and a content provider since it becomes very trivial to bind the content to ListViews using the Loader API.
According to the documentation about Data Storage, you have several options.
But the storage strategy that seems to meet your needs is an SQLite Database.
You can make use of SQLiteOpenHelper and ContentProvider to get it working.
It will require quite an amount of work and understanding to implement it but it's worth the effort :
Esier than other solutions to manipulate data once it stored.
A lot of android component are designed to work with databases cursors.
Easy to add new data and structures as your application evolves.
You will learn a lot about how develop android apps "the right way".
If i were you i would avoid :
SharedPreferences because this is not suited for list of data as there isn't any "id mechanism". On the other hand it is pretty easy to use for small settings.
Internal Storage because it is difficult to manipulate the data once it is stored. Also it is not the recommended way to store that type of data.

How to storing data in my own application

I would like to build some simple application - for example Todo list - and I am thinking about the problem and its solving - how can I to store data in my own application on Android platform?
I should to use some text file, xml file or some database? What will be better for beginner on this field?
You'll have a VERY hard time getting anywhere with Android if you don't read through their website/dev resources. I would highly recommend visiting their site.
As far as data storage is concerned, that varies based on your need. Explained here
My suggestion is to use SQLite that comes with Android. http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html
In my opinion, a SQLite database seems most appropriate for this kind of application. There is lots of support for using the SQLite database in conjuction with ListViews (which I imagine you'd want to use in your to-do list app).
In case you haven't already checked it out, see the page on the developer site:
http://developer.android.com/guide/topics/data/data-storage.html#db
Theres a few ways you can store data. I've created a few applications thats store data using shared preferences
They're quite handy for storing strings, ints, bool values etc. However if you have a large scaled application, that requires better database management, I would look into sqlLite.
Android has supported classes and functions to help access/store the information.
Theres a good tutorial on the android site called notepad that takes you through how to use sqlite.
That should get you started :)
Look at this Thread klick
Edit: its cool for less data, if you want to store and browse lots of data, you should use as SQLite Database
Using a file, database or xml based depends entirely on what kind of application you are building. For eg: If you parse an XML feed and store the results back in an XML file - it totally defeats the storage purpose!
Databases are used to store structured and related content like - news feed results, email client data, etc.
Files are more used for storing raw / binary content like storing images, attachments, etc.
BTW, if you are a beginner - you should try all of them! :)
Hope this helps!

Storage of Static data within android app

I am currently developing a simple info app on various university campuses. I want the app to operate predominantly in an offline state thus I want to store all my information locally. The data within the app will not be subject to any change thus I was wondering what the best (practice) method was to store such data? Basically should I be storing the info in a SQLite db, java file or xml?
The answer depends on your requirements, but because of the built-in integration with SQLite, the easiest will probably be to just use SQLite, plus you get the benefits of a relational database. You can refer to the Notepad tutorial for a start.
It depends on the data you have. If it is largely text I would store it in an android string resource file. If it is somehow structured and has IDs and relations store it in a database.
We had a University project requiring a local database on an android phone. What whe did was to use SQLite to write on a database stored on the memory stick. (We couldn't find the right permissions to write directly on the file system)
Check the API website for the android.database.sqlite package first.
And here for a nice tutorial :
http://www.devx.com/wireless/Article/40842

Categories

Resources