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 8717423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:10+00:00 2026-06-13T06:18:10+00:00

I must save an ArrayList of Ury so I use the code public static

  • 0

I must save an ArrayList of Ury so I use the code

public static void saveUriList(ArrayList<Uri> myUriList) {
        if (storageAvailable()) {
            try {
                FileOutputStream uriListSaved = new FileOutputStream(
                        baseDir + File.separator + filename);
                ObjectOutputStream uriList = new ObjectOutputStream(
                        uriListSaved);
                uriList.writeObject(myUriList);
                uriList.close();
            } catch (Exception exc) {
                exc.printStackTrace(); 
            }
        }

    }

This code structure works fine for custom object that implements serializable but with Uri objects returns this Exception

10-18 21:06:40.169: W/System.err(11957): java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: android.net.Uri$StringUri
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:933)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
10-18 21:06:40.169: W/System.err(11957):    at java.util.ArrayList.readObject(ArrayList.java:665)
10-18 21:06:40.169: W/System.err(11957):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 21:06:40.169: W/System.err(11957):    at java.lang.reflect.Method.invoke(Method.java:507)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1520)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1443)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2112)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:916)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
10-18 21:06:40.169: W/System.err(11957):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
10-18 21:06:40.169: W/System.err(11957):    at it.myApp.testApp.utility.FileArchiveManager.loadUriList(FileArchiveManager.java:158)
10-18 21:06:40.169: W/System.err(11957):    at it.myApp.testApp.MyClass.onCreate(MyClass.java:107)
10-18 21:06:40.169: W/System.err(11957):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-18 21:06:40.169: W/System.err(11957):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
10-18 21:06:40.169: W/System.err(11957):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
10-18 21:06:40.169: W/System.err(11957):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-18 21:06:40.169: W/System.err(11957):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
10-18 21:06:40.169: W/System.err(11957):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-18 21:06:40.169: W/System.err(11957):    at android.os.Looper.loop(Looper.java:130)
10-18 21:06:40.169: W/System.err(11957):    at android.app.ActivityThread.main(ActivityThread.java:3687)
10-18 21:06:40.179: W/System.err(11957):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 21:06:40.179: W/System.err(11957):    at java.lang.reflect.Method.invoke(Method.java:507)
10-18 21:06:40.179: W/System.err(11957):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
10-18 21:06:40.179: W/System.err(11957):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
10-18 21:06:40.179: W/System.err(11957):    at dalvik.system.NativeStart.main(Native Method)
10-18 21:06:40.179: W/System.err(11957): Caused by: java.io.NotSerializableException: android.net.Uri$StringUri
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1535)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
10-18 21:06:40.179: W/System.err(11957):    at java.util.ArrayList.writeObject(ArrayList.java:651)
10-18 21:06:40.179: W/System.err(11957):    at java.lang.reflect.Method.invokeNative(Native Method)
10-18 21:06:40.179: W/System.err(11957):    at java.lang.reflect.Method.invoke(Method.java:507)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1219)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
10-18 21:06:40.179: W/System.err(11957):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
10-18 21:06:40.179: W/System.err(11957):    at it.myApp.testApp.utility.FileArchiveManager.salvaListaPathImmagini(FileArchiveManager.java:127)
10-18 21:06:40.179: W/System.err(11957):    at it.myApp.testApp.LoadImage.onActivityResult(LoadImage.java:120)
10-18 21:06:40.179: W/System.err(11957):    at android.app.Activity.dispatchActivityResult(Activity.java:3908)
10-18 21:06:40.179: W/System.err(11957):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
10-18 21:06:40.179: W/System.err(11957):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
10-18 21:06:40.179: W/System.err(11957):    at android.app.ActivityThread.access$2000(ActivityThread.java:117)
10-18 21:06:40.179: W/System.err(11957):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
10-18 21:06:40.189: W/System.err(11957):    ... 8 more

I suppose that this happen because Uri doesn’t implements Serializable….

How could I fix this problem? Must I create a custom Uri Object?

  • 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-13T06:18:12+00:00Added an answer on June 13, 2026 at 6:18 am

    As you already noticed, Uri does not implement Serializable, see the reference android.net.Uri.
    How about storing your uris as Strings when writing your file, and converting them back to uris using Uri.parse() when reading the file?

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

Sidebar

Related Questions

Must be a way looping through this code: private void loadSprites() { this.sprites[0] =
I must save html source code in a sql database (for an android app).
I am working on a code that, among other things, must save a zero-filled
I have an application which must save client instances of com.smartgwt.client.widgets.Canvas to a disk
I am trying to test my show action, but I first must save an
I have a big problem. My program must save a Xml file with 3
I'm very newbie in ruby and need your help. I must save a Topic
I draw a screen with OpenGL commands. And I must save this screen to
Is there a difference between Session.Save and Transaction.Commit ? When I should use which?
I am searching a simple addslashes function for a program that must save in

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.