Android Question java.lang.RuntimeException: Object should be first initialized (List)

Neojoy

Member
Licensed User
Longtime User
I'm using List var to get all files from a folder, i ever tested if it was initialized before save on my database, but frequentily returns an error: Object should be first initialized (List).

Is there another parameter from List object that should be tested too?
 

Neojoy

Member
Licensed User
Longtime User
Can you post the relevant code and the full error message from the logs?

What happen if the folder was empty?
It returns a Null object?

if positive, I can check if is list is not null and go on with my code, correct?.
 
Upvote 0

Neojoy

Member
Licensed User
Longtime User
The list will not be initialized (not null) if there is no such folder.

You're right, I found the mistake, I was initialing my list var, but wasn't testing isinitialized parameter after get the list files

See part of my code:

files.Initialize
files = File.ListFiles(Folder)
For i = 0 To files.Size - 1...

It should be:

files = File.ListFiles(Folder)
if files.IsInitialized then
For i = 0 To files.Size - 1...
 
Upvote 0
Top