UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 78004

java.io.FileNotFoundException: (No such file or directory)

I am getting the following message in android LogCat

03-20 01:45:03.362: WARN/System.err(369): java.io.FileNotFoundException: /mnt/sdcard/LazyList/-2012431329 (No such file or directory)
03-20 01:45:03.362: WARN/System.err(369):     at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
03-20 01:45:03.372: WARN/System.err(369):     at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
03-20 01:45:03.382: WARN/System.err(369):     at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
03-20 01:45:03.382: WARN/System.err(369):     at java.io.FileOutputStream.<init>(FileOutputStream.java:66)
03-20 01:45:03.392: WARN/System.err(369):     at com.ImageLoaders.ImageLoader.getBitmap(ImageLoader.java:86)

For downloading images in android emulator I have added internet permission in androidManifest.xml file, but looks like it is not working. I have also given 10MB space to android emulator as well.

any one guide me what could be the problem? thanks in advance.

Upvotes: 12

Views: 31667

Answers (3)

Chrishan
Chrishan

Reputation: 4106

ImageLoader Constructor should be change to this.

public ImageLoader(Context context) {
    // Make the background thead low priority. This way it will not affect
    // the UI performance
    photoLoaderThread.setPriority(Thread.NORM_PRIORITY - 1);

    // Find the dir to save cached images
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
        cacheDir = new File(context.getCacheDir(), "LazyList");
    else
        cacheDir = context.getCacheDir();
    if (!cacheDir.exists())
        cacheDir.mkdirs();
}

By default it is like this

cacheDir = new File(android.os.Environment.getDataDirectory(), "LazyList");

You should change it to

cacheDir = new File(context.getCacheDir(), "LazyList");

I solved my problem 100% in android 2.1.

Upvotes: 1

Jose Manuel
Jose Manuel

Reputation: 807

I solved this problem adding permissions:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 29

anon
anon

Reputation:

You seem to search for the following directory or file:

/mnt/sdcard/LazyList/-2012431329

This is looking a little bit weird. This file or directory can't be found since it's not a valid name. Are you sure that this is the correct name?

Upvotes: 0

Related Questions