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

  • SEARCH
  • Home
  • 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 8689867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:45:53+00:00 2026-06-12T23:45:53+00:00

i am coding android app in which i ahve to add files into my

  • 0

i am coding android app in which i ahve to add files into my shared folder.

here is my code for to open dialog (for file browsing)

  Intent pickFileIntent = new Intent();
  pickFileIntent.setAction(Intent.ACTION_GET_CONTENT);
  pickFileIntent.addCategory(Intent.CATEGORY_OPENABLE);
  pickFileIntent.setType("*/*");
  Intent chooserIntent = Intent.createChooser(pickFileIntent,
  getText(R.string.choosefile_title));
  //Toast.makeText(FileShare.this, "",1).show();
  startActivityForResult(chooserIntent, PICK_FILE_REQUEST);

Its works well for Image and other mp3 files.
but when i click on file Browser it gives me error.
Following is the code of file browser and logcat

         public void onCreate(Bundle icicle) {
            super.onCreate(icicle);

            /* If no data is supplied, get default from the FileProvider */
            if (getIntent().getData() == null) {
              getIntent().setData(FileProvider.CONTENT_URI);
            }
            String currentPath = FileProvider.getPath(getIntent().getData());

            /* Special case for "/". Wouldn't need this is we have a class to 
             * do path joining for us */
            if (currentPath.equals("/"))
              currentPath = "";
           mPaths.push(currentPath);

            /* Populate list with the root content */
        //Error in following line when i debug
            Cursor c = managedQuery(getIntent().getData(), null, null, null, null);
            changeCursor(c);
            registerForContextMenu(getListView());
          }

LOGCAT

        10-08 19:18:55.867: E/AndroidRuntime(16386): FATAL EXCEPTION: main
        10-08 19:18:55.867: E/AndroidRuntime(16386): java.lang.RuntimeException: Unable
        to start activity   
                  ComponentInfo{com.fyp.fileshare/com.fyp.fileshare.FileBrowser}:                                                 
        java.lang.ClassCastException: java.lang.Integer
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at             
        android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.os.Handler.dispatchMessage(Handler.java:99)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.os.Looper.loop(Looper.java:130)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.ActivityThread.main(ActivityThread.java:3687)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.lang.reflect.Method.invokeNative(Native Method)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at             
        java.lang.reflect.Method.invoke(Method.java:507)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at dalvik.system.NativeStart.main(Native Method)
        10-08 19:18:55.867: E/AndroidRuntime(16386): Caused by: java.lang.ClassCastException: java.lang.Integer
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.fyp.fileshare.FileProvider$1.compare(FileProvider.java:103)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.fyp.fileshare.FileProvider$1.compare(FileProvider.java:1)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:320)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.util.TimSort.sort(TimSort.java:199)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.util.TimSort.sort(TimSort.java:169)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.util.Arrays.sort(Arrays.java:2090)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at java.util.Collections.sort(Collections.java:1965)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.fyp.fileshare.FileProvider.getCursorForFiles(FileProvider.java:101)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.fyp.fileshare.FileProvider.query(FileProvider.java:60)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.content.ContentProvider$Transport.query(ContentProvider.java:187)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.content.ContentResolver.query(ContentResolver.java:262)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.Activity.managedQuery(Activity.java:1550)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at com.fyp.fileshare.FileBrowser.onCreate(FileBrowser.java:68)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
        10-08 19:18:55.867: E/AndroidRuntime(16386):    ... 11 more

Lines from #100:

100// Sort listing by display name. 
101 Collections.sort(fileList, new Comparator<Object[]>() { 
102 public int compare(Object[] r1, Object[] r2) { 
103 return ((String) r1[1]).compareTo((String) r2[2]); } });
  • 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-12T23:45:55+00:00Added an answer on June 12, 2026 at 11:45 pm

    The problem is return ((String) r1[1]).compareTo((String) r2[2]); } One of those isn’t a String

    Answer By: njzk2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently coding an Android app, which will be used to count Traffic
I'm coding my first android app with fragments and here is my problem. I've
I'm coding an android app for parsing sms messages. I need different rules for
I'm coding an Android app through Phonegap and I'm at the point of installing
I'm coding a simple android application which contains a list, populated with a SimpleCursorAdapter.
I am looking to build a button in my Android app which must contain:
This is my .java file in src: package com.wao.texttime; import android.app.Activity; import android.os.Bundle; import
we have an app which is available for ipad, iphone, android as well as
I have the following code which searches a text file on my phone's sd
After finishing coding for my app, I started to get into the optimization part.

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.