J jschuchert Active Member Licensed User Longtime User Feb 13, 2013 #1 My project uses comma-delimited files of numbers like this: 1,1000,1000,point1 2,1027.699,1038.570,point2 3,1070.797,3456.123,point3 . . . etc When I first created the application, I used a file called 'sample.txt' with those types of numbers. I put the file the Files folder and then inserted it into the porgam with the following code: Code: Copy File.Copy(File.DirAssets ,"sample.txt",File.DirInternal ,"sample.txt") That works well. Today I tried to include similar files with this code: Code: Copy File.Copy(File.DirAssets ,"sample.txt",File.DirInternal ,"sample.txt") File.Copy(File.DirAssets ,"CommaDelimited.txt",File.DirInternal ,"CommaDelimited.txt") File.Copy(File.DirAssets ,"jim05.txt",File.DirInternal ,"jim05.txt") but the others don't work. They are not being found although they are also in the "Files" folder and appear in the IDE Files tab. That's the first problem. Second issue: When a user 'imports' a new file (comma-delimited database) into the program by copying it from his computer to the internal directory on his device, shouldn't that file now be usable as though it had come from the 'assets' folder or would that only work with an 'apk' file? It is important that I be able to import comma-delimited files, and parse them for calculations. Thanks for any help. Jim
My project uses comma-delimited files of numbers like this: 1,1000,1000,point1 2,1027.699,1038.570,point2 3,1070.797,3456.123,point3 . . . etc When I first created the application, I used a file called 'sample.txt' with those types of numbers. I put the file the Files folder and then inserted it into the porgam with the following code: Code: Copy File.Copy(File.DirAssets ,"sample.txt",File.DirInternal ,"sample.txt") That works well. Today I tried to include similar files with this code: Code: Copy File.Copy(File.DirAssets ,"sample.txt",File.DirInternal ,"sample.txt") File.Copy(File.DirAssets ,"CommaDelimited.txt",File.DirInternal ,"CommaDelimited.txt") File.Copy(File.DirAssets ,"jim05.txt",File.DirInternal ,"jim05.txt") but the others don't work. They are not being found although they are also in the "Files" folder and appear in the IDE Files tab. That's the first problem. Second issue: When a user 'imports' a new file (comma-delimited database) into the program by copying it from his computer to the internal directory on his device, shouldn't that file now be usable as though it had come from the 'assets' folder or would that only work with an 'apk' file? It is important that I be able to import comma-delimited files, and parse them for calculations. Thanks for any help. Jim
Erel B4X founder Staff member Licensed User Longtime User Feb 13, 2013 #2 They are not being found Click to expand... Can you post the code that accesses these files? When a user 'imports' a new file (comma-delimited database) into the program by copying it from his computer to the internal directory on his device Click to expand... The user cannot copy a file to your application internal folder. The user can copy files to the storage card: File.DirRootExternal. Upvote 0
They are not being found Click to expand... Can you post the code that accesses these files? When a user 'imports' a new file (comma-delimited database) into the program by copying it from his computer to the internal directory on his device Click to expand... The user cannot copy a file to your application internal folder. The user can copy files to the storage card: File.DirRootExternal.
mc73 Well-Known Member Licensed User Longtime User Feb 13, 2013 #3 I don't know about your first issue (how is user supposed to open your added files?) but for the second issue what I do know is that a user normally cannot add files to your apps internal directory (unless the device is rooted). You should provide an option to read data from your apps dir.DefaultExternal. Upvote 0
I don't know about your first issue (how is user supposed to open your added files?) but for the second issue what I do know is that a user normally cannot add files to your apps internal directory (unless the device is rooted). You should provide an option to read data from your apps dir.DefaultExternal.
J jschuchert Active Member Licensed User Longtime User Feb 13, 2013 #4 My device is a nexus 7 ( not rooted) without an sd card so I have to do it with usb but I have noticed that in some instances, a message says "your file is on the sd card" but only sometimes. I have another device with an sd card that I will try it on and see what happens. Erel: Here is a portion of the code that applies: Code: Copy BtnOK_click reader.Initialize (File.openinput(File.Dirinternal ,Main.strfilename )) lineoftext=reader.ReadLine 'first line contains data but doesn't pick it up If lineoftext=Null Then Msgbox("There are no points in this file","Warning") Return True End If cline=Regex.Split (",",lineoftext) 'num=cline(0) high=cline(0) lineoftext=reader.ReadLine Do While lineoftext<>Null cline=Regex.Split (",",lineoftext) If cline(0)> high Then high=cline(0) Else 'num = high 'Exit End If ''xx=xx+1 lineoftext=reader.ReadLine Loop 'Log(high) . . etc End Sub Strangely, it works with the 'sample' file but not the jim05 file or the other one. Upvote 0
My device is a nexus 7 ( not rooted) without an sd card so I have to do it with usb but I have noticed that in some instances, a message says "your file is on the sd card" but only sometimes. I have another device with an sd card that I will try it on and see what happens. Erel: Here is a portion of the code that applies: Code: Copy BtnOK_click reader.Initialize (File.openinput(File.Dirinternal ,Main.strfilename )) lineoftext=reader.ReadLine 'first line contains data but doesn't pick it up If lineoftext=Null Then Msgbox("There are no points in this file","Warning") Return True End If cline=Regex.Split (",",lineoftext) 'num=cline(0) high=cline(0) lineoftext=reader.ReadLine Do While lineoftext<>Null cline=Regex.Split (",",lineoftext) If cline(0)> high Then high=cline(0) Else 'num = high 'Exit End If ''xx=xx+1 lineoftext=reader.ReadLine Loop 'Log(high) . . etc End Sub Strangely, it works with the 'sample' file but not the jim05 file or the other one.
Erel B4X founder Staff member Licensed User Longtime User Feb 14, 2013 #5 Note that you can access the file directly from File.DirAssets. Also make sure that there is no case issues as Android file system is case sensitive. Upvote 0
Note that you can access the file directly from File.DirAssets. Also make sure that there is no case issues as Android file system is case sensitive.
J jschuchert Active Member Licensed User Longtime User Feb 14, 2013 #6 :BangHead: Before I post more code, I have some elementary questions that may save time. The files I refer to below are comma delimited text files containing numbers like shown at the beginning of this thread: 1.What is the 'Assets' folder and are the files shown in the list when I select the 'Files' tab at the bottom right of the IDE contained therein? What are the restrictions for this folder and how can I use it to my advantage? 2. Can a file be copied from DirAssets to DirInternal? 3. Can a file be copied from DirRootExternal to DirInternal and vice-versa? 4. What is difference between DirRootExternal and DirDeiaultExternal and when should they be used? 5. Can multiple files be copied consecutively from DirAssets to DirInternal? In other words, may multiple files exist in dirInternal and accessed when called? 6. When I re-compile while my device is connected to the bridge, isn't that the same as re-installing the apk? Bottom line...All I want to do is be able to transfer comma-delimited files back and forth. I am confident it can be done. When I first developed my application, I must have been able to do it or I wouldn't have had it as an option. I just don't remember how. Obviously there are problems with my code that prevents it but not questioned until recently. I guess not all users needed that feature but I now have a user who does. I really appreciate the time all of you experts give for those like me. This is excellent software and I commend Erel and others for its development. Thanks for your assistance. Jim Upvote 0
:BangHead: Before I post more code, I have some elementary questions that may save time. The files I refer to below are comma delimited text files containing numbers like shown at the beginning of this thread: 1.What is the 'Assets' folder and are the files shown in the list when I select the 'Files' tab at the bottom right of the IDE contained therein? What are the restrictions for this folder and how can I use it to my advantage? 2. Can a file be copied from DirAssets to DirInternal? 3. Can a file be copied from DirRootExternal to DirInternal and vice-versa? 4. What is difference between DirRootExternal and DirDeiaultExternal and when should they be used? 5. Can multiple files be copied consecutively from DirAssets to DirInternal? In other words, may multiple files exist in dirInternal and accessed when called? 6. When I re-compile while my device is connected to the bridge, isn't that the same as re-installing the apk? Bottom line...All I want to do is be able to transfer comma-delimited files back and forth. I am confident it can be done. When I first developed my application, I must have been able to do it or I wouldn't have had it as an option. I just don't remember how. Obviously there are problems with my code that prevents it but not questioned until recently. I guess not all users needed that feature but I now have a user who does. I really appreciate the time all of you experts give for those like me. This is excellent software and I commend Erel and others for its development. Thanks for your assistance. Jim
J jschuchert Active Member Licensed User Longtime User Feb 15, 2013 #7 Please forgive my ignorance. I was just frustrated that things were not coming together. I found the answers I needed in the Help section. Jim Upvote 0
Please forgive my ignorance. I was just frustrated that things were not coming together. I found the answers I needed in the Help section. Jim