Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:00:35+00:00 2026-06-12T22:00:35+00:00

I am developing an Android app for finding duplicate files. till now i have

  • 0

I am developing an Android app for finding duplicate files.
till now i have developed directory explorer activity.
user will select the directory through this activity, then i am starting a service in separate process to list all files in that directory (using DFS algorithm) and to find all the duplicates among them.

for now i want to show the list of all the files in that directory and its sub-directory in separate activity.
i am using ArrayList to hold the file object and want to pass this ArrayList from this service to Activity.
I am writing the ArrayList to a file “filelist.bin” in the service and want to read that file from the Activity and here i am getting the error !! .

Also for launching the activity i am using Notification which is thrown by service when it has complete listing all the files and adding them to ArrayList.

i am getting Resource not found exception when i am trying to read the file. All the error details is listed at the end.

Below is the code for your reference (Code of Service)

public class BgService extends Service {

static String DIR0;
//public static ArrayList<FileX> OnlyFiles = new ArrayList<FileX>();

public static Stack<File> dirStack = new Stack<File>();
public static File file0;
public static File[] filearray;

static int size=0;
static FileX file2;

public static ArrayList<File> sOnlyFiles = new ArrayList<File>();
ArrayList<File> ListoFile;
static String hash1,hash2;
static ArrayList<Integer> Index2Del= new ArrayList<Integer>();
ArrayList<FileX> localOF;

FileOutputStream fos ;
FileInputStream fis;
ObjectOutputStream obs;
ObjectInputStream obsi;

@Override

public void onCreate() {
    // TODO Auto-generated method stub
    //Toast.makeText(getApplicationContext(), "service created",5000).show();


    super.onCreate();

}


@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    DIR0 = new String( intent.getCharArrayExtra("dir0"));
    listAllfiles();

    Collections.sort(sOnlyFiles, SizeFileComparator.SIZE_COMPARATOR);

    serializeList();
    //deserializeList();
    /*
    int size = ListoFile.size();
    for(int i = 0;i<size;i++){
        Toast.makeText(getApplicationContext(),String.valueOf(ListoFile.get(i).length()),1000).show();
    }*/

    displayNotification();
    this.stopSelf();
    return super.onStartCommand(intent, flags, startId);

}


@Override
public void onDestroy() {
    // TODO Auto-generated method stub
    //Toast.makeText(getApplicationContext(), "service destroyed",5000).show();
    super.onDestroy();
}




public void listAllfiles(){

           dirStack.push(new File(DIR0));

    while(dirStack.size()!=0){

        file0 = dirStack.pop();
        filearray=file0.listFiles();

        for(File lookFile : filearray){
            if(lookFile.isFile() && lookFile.canRead()){
                sOnlyFiles.add(lookFile);
                DataHolder.Dcounter++;
            }
            else if(lookFile.isDirectory()&& lookFile.canRead()){
                dirStack.push(lookFile);
            }
        }

    }
}

public void serializeList()  {
String filename = "filelist.bin";
File dir = getDir("DFR", MODE_PRIVATE);

try {
    Resources res = Resources.getSystem();
     fos = openFileOutput(filename, MODE_PRIVATE);
    obs = new ObjectOutputStream(fos);
    obs.writeObject(sOnlyFiles);
    obs.flush();
    obs.close();
    fos.close();

} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

}


public void displayNotification(){
    NotificationManager nm = (NotificationManager)getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
        Intent i = new Intent(getApplicationContext(),AllFiles.class);
    //  Bundle listfile = new Bundle();
    //listfile.putStringArrayList("listfile", sOnlyFiles);
        //i.putExtra(name, value)
        //i.putExtra("filelist", sOnlyFiles);

        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
        Notification nf = new Notification(R.drawable.ic_launcher,"Duplicate File Remover\n"+ DataHolder.Dcounter+"  files found",System.currentTimeMillis());

        nf.setLatestEventInfo(getApplicationContext(), "Duplicate File Remover",  DataHolder.Dcounter+" files found",pi);
        nf.vibrate = new long[]{100,250,100,500};
        nm.notify(1,nf);


}
@Override
public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    return null;
}
}

(Code of Activity)

public class AllFiles extends ListActivity{

FileInputStream fis ;
ObjectInputStream obs;

public static ArrayList<File> ListoFiles;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        stopService(new Intent(this, BgService.class));

        deserializeList();


    //  stopService(new Intent(this, BgService.class));
        //setListAdapter(new OnlyFilesAdapter());
        //Bundle filelist = getIntent().getExtras();
        super.onCreate(savedInstanceState);


    }

public void deserializeList(){
Object tolist =null;
String filename = "filelist.bin";

try {

    fis = openFileInput(filename);
    if(fis!=null){
        obs = new ObjectInputStream(fis);
        tolist = obs.readObject();
        @SuppressWarnings("unchecked")
        ArrayList<File> tolist2 = (ArrayList<File>)tolist;
        ListoFiles = tolist2;
        obs.close();
        fis.close();
        Toast.makeText(getApplicationContext(), ListoFiles.size(), 5000).show();
    }else
        Toast.makeText(getApplicationContext(), "file not available", 2000).show();


} catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}catch (ClassNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

}

LogCat Values on Error :-

10-14 13:30:33.018: W/ResourceType(433): No package identifier when getting value for resource number 0x0000001b
10-14 13:30:33.070: D/AndroidRuntime(433): Shutting down VM
10-14 13:30:33.070: W/dalvikvm(433): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-14 13:30:33.269: E/AndroidRuntime(433): FATAL EXCEPTION: main
10-14 13:30:33.269: E/AndroidRuntime(433): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.com.filebrowser/my.com.filebrowser.AllFiles}: android.content.res.Resources$NotFoundException: String resource ID #0x1b
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.os.Looper.loop(Looper.java:123)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-14 13:30:33.269: E/AndroidRuntime(433):  at java.lang.reflect.Method.invokeNative(Native Method)
10-14 13:30:33.269: E/AndroidRuntime(433):  at java.lang.reflect.Method.invoke(Method.java:507)
10-14 13:30:33.269: E/AndroidRuntime(433):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-14 13:30:33.269: E/AndroidRuntime(433):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-14 13:30:33.269: E/AndroidRuntime(433):  at dalvik.system.NativeStart.main(Native Method)
10-14 13:30:33.269: E/AndroidRuntime(433): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1b
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.content.res.Resources.getText(Resources.java:201)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.widget.Toast.makeText(Toast.java:258)
10-14 13:30:33.269: E/AndroidRuntime(433):  at my.com.filebrowser.AllFiles.deserializeList(AllFiles.java:60)
10-14 13:30:33.269: E/AndroidRuntime(433):  at my.com.filebrowser.AllFiles.onCreate(AllFiles.java:34)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-14 13:30:33.269: E/AndroidRuntime(433):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-14 13:30:33.269: E/AndroidRuntime(433):  ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:00:37+00:00Added an answer on June 12, 2026 at 10:00 pm

    In this line of code:

    Toast.makeText(getApplicationContext(), ListoFiles.size(), 5000).show();
    

    ListoFiles.size() returns in int. If you call

    Toast.makeText(Context context, int resId, int duration)
    

    then the API expects the second paramter to be the ID of a string resource. In your case it isn’t. If you just want to show a toast with a number in it, try this:

    Toast.makeText(getApplicationContext(), "" + ListoFiles.size(), 5000).show();
    

    or

    Toast.makeText(getApplicationContext(), Integer.toString(ListoFiles.size()), 5000).show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was developing android app on eclipse till now and now I'm using Mono
i am developing an android app using phonegap. I have trouble displaying special characters
I'm developing an Android app in Eclipse Helios and I appear to have accidentally
I am developing an android app in which I have included a library project,
hey, does anyone have experience in developing Android app with Java reflection feature? I
I am developing an Android app. I have a custom button with a .9.png
I am currently developing an Android app i previously developed for IPhone. My Backend
I'm developing android app. It's some sort of social network. Where user can add
I'm developing an Android app where the user is allowed to rest his hand
I developing an Android App to solve the Rubiks Cube. First the Cube will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.