Reading file from android directory

I have the following problem:

  1. have a text file in my documents directory (android)
  2. my application should be able to read it

I thought that

`local` `path = system.pathForFile( ` `"myfile.txt"` `, system.DocumentsDirectory )`

would read the file I put in the phone documents directory, but it doesn’t!

Why? How can I read “myfile.txt”?

That’s not the Documents directory of the phone, that’s the app’s documents directory that your app can write to.

I’ve understood that, but how can I read the phone directory?

If you maybe haven’t, Here you can read everything about reading and writing files:
Solar2D Documentation — Developer Guides | Data/Files/Strings (coronalabs.com)

Really Good read!

There’s also Scott’s plugin here - Scott H Tech - but I’ve never used it.

1 Like

@proV I know that. But it doesn’t say anything about the documents directory of the phone!

@GrahamRanson1 thanks, I’ll try it. It’s a pity that Corona SDK doesn’t have a native function!

On the other hand though it’s great that plugin developers can help carry the load so that Vlad and his team can work on larger core improvements.

@GrahamRanson1 that plugin costs $9.99! I paid and I discovered that it works only on SD card!

Sorry like I said I’ve never used it before so it might be worth contacting Scott about usage/features/support etc

However I don’t think $10 is that steep really. Scott’s had to develop, test, and support the plugin and then attempt to sell it to a small market.

It has to be priced according to the cost to develop ( and support ) divided by by the expected number of purchases.

2 Likes

Also, and not to blame anyone, but the second paragraph on the page reads:

image

1 Like

@GrahamRanson1 I was surprising because it was the first time I had to use a plugin and because Solar2D is free I thought that even the plugin was free. That’s all. Anyone who does something has the right to be paid!

Again, I am not casting blame on anyone, but there is no mention of the word “apk” on the page.

There are two storage types: internal and external. External storage refers to removable volumes, like SD cards.

Like you said, there is no need for everyone to be an expert. That is one of the many reasons why plugins exist, so not everyone needs to know how to do these more complex things. However, whenever you are making purchases, you should always know what you are buying. If you aren’t certain about something, then just ask. :+1:

1 Like

Wow! You didn’t want to put blame on someone!

My question was:

I have the following problem:

  1. have a text file in my documents directory (android)
  2. my application should be able to read it

I thought that

`local` `path = system.pathForFile( ` `"myfile.txt"` `, system.DocumentsDirectory )`

would read the file I put in the phone documents directory, but it doesn’t!

Why? How can I read “myfile.txt”?

Your premise is just wrong. Operating systems sandbox apps to stop these things specifically to stop malware, etc.

Your application can read it’s own documents folder stored in your apps sandbox/apk.

1 Like

Corona Marketplace – Recent featured products 10 Nov | Corona Labs

@SGS my premise is not wrong! Perhaps it is not possible, but not wrong! Sorry.

@GrahamRanson1 “Scott’s had to develop, test, and support the plugin”.

The plugin doesn’t work! Because reporting to him that the plugin did work he, who tested etc., modifying the plugin and the documentation but it still doesn’t work!

Hey already replied to your email, but I updated the demo.

You should get the new pop up and you need all access to write and read to phone.