Android Question Cannot get list item into EditText

Discussion in 'Android Questions' started by Cristofayre, Mar 24, 2015.

  1. Cristofayre

    Cristofayre Member

    This is probably "blindingly obvious" to a regular user, but it's thrown me! (Programming 3 days!) Upfront, I'll say I'm using the debugger, and not a physical device if that is causing error.

    Dim SavedUserData As String
    Dim inUserData As List
    Dim savedCopy As String ' Tried as string and as object
    Dim savedTitle As Object
    Dim savedKey As Object
    Dim savedDesc As Object

    SavedUserData = File.DirRootExternal & "user.db"
    SavedUserData = File.DirRootExternal & "/user.db" 'Both options tried

    If File.Exists(SavedUserData, "") = False Then
    Dim userList As List
    userList.AddAll(Array As String("Enter your copyright details","Enter your title","Enter your keywords","Enter your description"))

    File.OpenOutput(File.DirRootExternal,"user.db",True) ' Append to list / create list
    inUserData=File.ReadList(File.DirRootExternal,"user.db") As List
    >> photo_copy_in.Text=inUserData.Get(0)
    End If

    javac 1.7.0_76
    shell\src\b4a\example\ error: ';' expected
    _inuserdata = main.mostCurrent.__c.getField(false,"File").runMethod(false,"ReadList",(Object)(main.mostCurrent.__c.getField(false,"File").runMethod(true,"getDirRootExternal")),(Object)(RemoteObject.createImmutable("user.db")));Debug.locals.put("inUserData", _inuserdata)} BA.debugLineNum = 80;BA.debugLine="photo_copy_in.Text=inUserData.Get(0)";

    What SHOULD happen is that if "user.db" doesn't exist, it creates a list, and writes that out to ???
    If it DOES exist, it loads that database, and then reads the four values into strings / objects (tried both) and in the latter 4 lines loads it into EditText fields on a panel

    I tried it with "DirInternal", but still stops at same line. I think it's 90% correct, just keeps fouling up with a syntax errror or something at >> These four variables are declared in Globals, and this is within Activity_Create within a FirstTime block (Report says it's missing a ";" ... but where's that coming from??

    Shame, as I was going so well until this hit!!

    Sorry to forum users. Just noticed there is an edit button on the original posting - presumably to add updates etc. I wil know to do that in future!

    Seems it's impossible to write back to a EditText field. Hope someone can advise whether this is simply because I need to upgrade from FREE to PAID, or whether such an action is impossible with B4A. (I've seen on StackOverflow an option called "SetText" ... but that's not on the freebie!)
    Last edited: Mar 25, 2015
  2. Cristofayre

    Cristofayre Member

    I MIGHT have solved part of it.

    I've now tried putting the text string into an array first, and then Add-ing the array to the userList. That SHOULD (in theory) then write the list out to ????

    I use the question marks 'cos although it compiles and runs on the emulator, I've yet to locate "user.db" anywhere on PC, (unless it's coded in with the compile code? Unfortunately, although I specified "user.db", Windows "Find" gives me lots of files containing or ending with "db"

    And I still can't read the data back in again - if saved at all - due to a syntax error as above!!

    If File.Exists(SavedUserData, "") = False Then
    Dim userList As List
    Dim arr(4) As String
    arr(0)="Enter your copyright details"
    arr(1)="Enter your copyright details"
    arr(2)="Enter your title"
    arr(3)="Enter your description"
  3. Cristofayre

    Cristofayre Member

    Just thought I'd try a Msgbox(SavedUserData) to locate the root memory folder. Of interest to anyone, seems that -on the trial at least - it came up with "data/data/b4a.example/files/user.db" So it MUST be stored within code since b4a.example with the dot is not a valid Windows directory name. So can't even check if that file IS being written out!

    Yep, as I thought! More research shows that unlike Windows, with Android you cannot view the physical folders that MakeDir and similar create, (so how you're supposed to see what data was saved - indeed if it was saved at all - I don't know)

    Whilst the free version says a folder has been created via the File.Exist option, it also tells me that I have an external SD card attached to my PC hen folder is created with DirRootExternal- which is incorrect. So does it use memory as a psuedo card cache? Who knows. Can't see anything about it in guide

    Sorry for the negative tone, but after starting so well, I'm now hitting hurdle after hurdle!
    Last edited: Mar 25, 2015
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice