Hunt
Hunt

Reputation: 8435

file fetching approach

I am trying to read files from a particular folder in Android , i have two ways to do it:

1) use the typical approach is as follows

   File mainLoc = Environment.getExternalStorageDirectory();
   File folderLoc = new File(mainLoc , "/foldername/");

and after then fetch it using file name filters.

2) another way is to using BroadcastReceiver

   IntentFilter filter = new IntentFilter();
   filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
   filter.addAction(Intent.ACTION_MEDIA_REMOVED);

so i really don't know wht is the difference between these approaches and which is efficient and represents the best practice ?

Upvotes: 0

Views: 88

Answers (1)

Rajdeep Dua
Rajdeep Dua

Reputation: 11230

As far as i understand these Intents are only triggered when external media is mounted or unmounted. So you can't use that approach unless these intents are triggered.

Upvotes: 1

Related Questions