+ 2
Java - How to create a file on phone using JvDroid?
In Java tutorial, we are taught to work with files on computer. How to work with files on our phone?🤔 I already used JvDroid I have a file named kira.txt in my internal storage. File f= new File("kira.txt") System.out.print( f.exists() ); Why the output is false?
12 Respuestas
+ 3
that's an example of my internal storage ;)
in fact internal storage is usually named 'sdcard' (think of it as an unmovable sdcard)
android use linux/unix file system... external sd are mounted to miscelanous directory names under /sdcard/ (could differ related to phone manufacterer...) and could be mounted at different places at same time (different valid path to access same sd/directories)
the simpler and safest to get the path of your file would be to use a file explorator wich could give it to you (almost all decents: I currently use an old version of ES File Explorer, and Total Commander on an old phone)...
on my old phone the paths look like:
/storage/sdCard0/download/file.txt
for internal storage
and
/storage/extSdCard/folder/fike.txt
for external storage
+ 2
visph I use JvDroid on my phone
+ 2
I don't know: maybe it's either a problem of you're not executing the code in the directory containing the file (working directory: may be different of those where the script/executable reside), or a problem related to file permissions: android tends to be very strict about that ;P
+ 2
something like:
/sdcard/Download/file.txt
absolute path must start with a slash (root is /)
without the starting slash, the path will be relative to the current working directory (folder)
+ 2
visph Martin Taylor It worked!!👍👍. I successfully created a txt file in my internal storage
+ 1
if you run your code in sololearn playground, then it is executed on sololearn servers, so you try to access their local file system, not your phone file system ^^
+ 1
visph How to specify path of a file in an Android phone?🤔
+ 1
visph 😅 If the file is in the internal storage?🤔
0
Use Java n-ide not available on playstore