Cache video list in android - android

I'm building a video player. I've thousands of video files stored in both internal and external storage. So my video listview is very long and take time to load. my listview contains an imageview and a text view. I can cache the thumbnails, but don't know what to do with the list.. any idea???

Be simple...
don't make every thing dynamic, unless it would be a critical thing.
Use sqllite, txt file or xml to store the lists of names, pathes ... etc.
It will increase the performance dramatically.
Best

You should not load all the contents at the same time. use a LRUcache to store a few thumbnails and add/delete one element each time you need a new image. Simply show a progress dialog before loading success. Refer this for usage of LruCache.
You can refresh the image data in getView method

Try this this can be helpful for you

Use MediaStore and ListAdapter. MediaStore is already managing thumbnails and filesystem paths for all media types (photo, video and audio).
Here's an article covering the basics of content providers, aka databases, which is what MediaStore is.
Here's an example of querying MediaStore for videos.
Also, this stackoverflow question seems similar to what you're doing.
One more thing: if you need to load media over the network (instead of local filesystem) then use the ContentProvider+Service technique described by Virgil Dobjanschi in his talk from Google I/O 2010 (video,pdf). At first it will seeem like overkill but the upfront work will pay repeated dividends in performance, avoiding caching bugs and avoiding rework.

Related

Should you use a database for storing videos or video url?

I am making an app for android which uses quite a lot of images and videos so I decided a MySQL database would be the best idea for storing all the media. I have never done this before and when I looked around to try and find out how I could go about storing videos in a database, I was told that it is generally not a good idea to store whole videos in a database. Could someone please explain why this isn't a good idea, as I have looked around and can't find any decent info on the subject.
What I have done though is instead of storing the whole video as a blob, I instead stored a string of the url that links to the video. Is this how storing videos is usually done?
Look, even when most relational databases such as MySQL can habdle media content, they are designed to store text information (characters, numbers, etc).
If you use your database to store images and/or video, everytime you run a query to get the content, the database will be working so hard because you're storing/reading a huge amount of data and database motor will have to reconstruct all the content on every query, and also, you may have to do some tricks to read it as a stream. This will impact the performance of your system in a negative way.
Remember that you'll be using that content so often, which means database will be handling a heavy load.
I suggest you use the database to store the URL's of the contents and just use it to retrieve the url of the element you want to use.
I Agreed storing video is not a good idea in database coz time comes up that you gonna face a serious problem when it comes of fetching data if you already have a bunch of videos and images in your tables. Must better to make it a file system then store the path at your table.
Good luck!

Dynamic Loading in Listview Android

My DataBase contains 1000's of images on server , I have to display these images in ListView in Android.
I have to develop similar List like that in the Flipcart app(If User Scroll then download Images) and store a local copy in SQlite and display from that SQlite database.
(In future if connectivity would not be there then also I would be able to run my app)
because Images will be available in SQlite.
Please suggest proper Solution for that.
Use of loaderManager or something else please suggest
I don't advise towards storing the images themselves in the SQLite database. The database will become slower to use and more cumbersome. Also, I think you should not implement such complex functionality yourself as there are many ready to use open source solutions.
There are a lot of solutions that allow you to cache the images on the file storage. They work transparently - when you request url they first check the local cache and only if this check does not exist they will make network call. Most of them also will display default thumbnail until the network call succeeds. Basically I think this is the best you can do.
I, myself have used Universal Image loader for what I describe, but out of this thread you can find many alternatives.

Android best way to retrieve images and view them from external source

I'm going to be making a wallpaper app but need some guidance on how I am going to be able to store, retrieve and view the wallpapers.
Will I need to make use of ImageView so I will be able to display the images?
I'm going to need some sort of database/website to store all of the wallpapers on. What would be the best thing to do, use a database or a website?
How would I go about retrieving the wallpapers from my chosen source?
Any help/advice would be appreciated, thanks.
A common practice is to use an rss feed of images. Then, just hook up your app to the rss feed and have it check for updates periodically.
Here is a reference on reading xml (rss) in Android:
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
Good luck.
you can try aquery android library for lazy loading image. this library store images in cache memory so you not need to store it externally also it will take some time for first time loading image from web but once it load in your application then it will automatically store in cache so second time take very less time to display also its less time consuming then other lazzy loading methods..below code may help you.....
AQuery aq = new AQuery(mContext);
aq.id(R.id.image1).image("http://data.whicdn.com/images/63995806/original.jpg");
You can download library from from this link
Personally I would use a database. But the easiest option would be to use the 'res/drawable' folder in android I guess.
If you stored them on the internet and haven't got connectivity, you can't get your images, so users won't necessarily like this.
To get at them from a database you'll likely have to know some SQL or know someone who knows a bit of SQL. The advantage of storing them in a database would be that it's one neat package and it is portable.
Don't worry about using ImageView it, you just need to get the image from the source (database /filesystem etc..) and give it to the imageView

Extending SimpleCursor Adapter

I'm new to android development and i was looking for simplest explanation for using the SimpleCursorAdapter class with a cursorloader for pulling out Video Thumbnails and details from my android device. I'm doing a mini video file browser in my app which i am using a gridView, a Fragment, and some content providers pointing to some external URI. Any form of help will be very much appreciated
Take a look at the Android training guides.
The guide Loading Data in the Background shows you how to set up a CursorLoader and use it to get data from a content provider.
The guide Sending Operations to Multiple Threads shows you how to do work on a background thread. It includes sample code for downloading, caching, decoding, and displaying images, which is pretty close to what you're doing.
The second guide makes extensive use of Fragments.
I'm not sure what you mean by a content provider that "points to some external URI". Content providers can be backed by any type of data, but they're best suited to structured data that exists on the device.
For an example of downloading images in the background, take a look at here.
I used this in a ListView and it works nicely to download images on another thread as well as managing a cache of the images. Easy callbacks are used and I implemented a view switcher in my list to allow an easy transition from the placeholder image to the real, downloaded image.

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.

Categories

Resources