/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/org/waxworlds/edam/importcontacts/FileChooser.java

  • Committer: edam
  • Date: 2010-12-16 00:16:01 UTC
  • Revision ID: edam@waxworlds.org-20101216001601-tb8g7tsw55v9qe18
- determine path to SD card by querying android
- added error when no SD card can be found

Show diffs side-by-side

added added

removed removed

25
25
 
26
26
import java.io.File;
27
27
import java.io.FileFilter;
 
28
import java.io.IOException;
28
29
import java.util.ArrayList;
29
30
import java.util.Collections;
30
31
import java.util.Comparator;
33
34
import android.app.Dialog;
34
35
import android.content.Context;
35
36
import android.content.DialogInterface;
 
37
import android.os.Environment;
36
38
import android.view.LayoutInflater;
37
39
import android.view.View;
38
40
import android.view.View.OnClickListener;
322
324
 
323
325
        public static int pathIcon( String path )
324
326
        {
325
 
                if( path.equals( "/sdcard/" ) )
 
327
                // get sdcard path
 
328
                String sdcard_path;
 
329
                try {
 
330
                        sdcard_path = Environment.getExternalStorageDirectory()
 
331
                                .getCanonicalPath();
 
332
                        if( sdcard_path.charAt( sdcard_path.length() - 1 ) != '/' )
 
333
                                sdcard_path += "/";
 
334
                }
 
335
                catch( IOException e ) {
 
336
                        sdcard_path = null;
 
337
                }
 
338
 
 
339
                // special paths
 
340
                if( path.equals( sdcard_path ) )
326
341
                        return R.drawable.sdcard;
327
342
 
 
343
                // default
328
344
                return R.drawable.directory;
329
345
        }
330
346
 
332
348
        {
333
349
                String path = full_path;
334
350
 
 
351
                // get sdcard path
 
352
                String sdcard_path;
 
353
                try {
 
354
                        sdcard_path = Environment.getExternalStorageDirectory()
 
355
                                .getCanonicalPath();
 
356
                        if( sdcard_path.charAt( sdcard_path.length() - 1 ) != '/' )
 
357
                                sdcard_path += "/";
 
358
                }
 
359
                catch( IOException e ) {
 
360
                        sdcard_path = null;
 
361
                }
 
362
 
335
363
                // special names
336
 
                if( path.equals( "/sdcard/" ) )
 
364
                if( sdcard_path != null && path.equals( sdcard_path ) )
337
365
                        return " " + _context.getString( R.string.filechooser_path_sdcard );
338
366
 
339
367
                // remove prefix, if present