About Store Forum Documentation Contact



Post Reply 
Android: file in storage not created
Author Message
Houge Offline
Member

Post: #1
Android: file in storage not created
Hello, i need some help with creating files on android.
What i need:
1. Create sqlite database
2. Insert some rows inside
3. Read rows

Sample project is in attachment.
When building on PC it works fine, but on Android file is not created and sqlite say "SQL not connected".

What am i doing wrong? I tried to find a place to create a file with function SystemPath() and i tried to use almost all SYSTEM_PATH types that are connected to mobile devices, but no luck.

Tested on Galaxy Note 2 (Android 4.4) and Galaxy S7 (Android 6), results are the same.


Attached File(s)
.zip  sqlite_android.zip (Size: 1.27 KB / Downloads: 4)
09-13-2016 09:23 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Android: file in storage not created
Are you adding a slash after system path?
SystemPath(SP_APP_DATA).tailSlash(true)+"file.db"
Should work fine
09-14-2016 01:53 AM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #3
RE: Android: file in storage not created
Yes, i use:
Code:
#if MOBILE
    path = SystemPath(SP_APP_DATA);
    path = path.tailSlash(true) + "testdb.db";
#endif
09-14-2016 05:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Android: file in storage not created
Thank you for reporting the issue.

I was able to reproduce the problem with the provided project.
I will investigate this and try to solve the problem ASAP.
09-14-2016 10:33 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Android: file in storage not created
Sorry for the problem.
Simply forgot to convert \ slashes to / on non-Windows platforms for SQLite function smile
Fix is now available on GitHub.
Tested on Galaxy Note4 and works OK now.
09-14-2016 10:53 AM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #6
RE: Android: file in storage not created
Thank you very much! I will check it later today smile
09-14-2016 11:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #7
RE: Android: file in storage not created
I thought everyone used / for paths, I know I do(whenever I see a \ I make it / ). smile
Glad this was fixed though. wink
(This post was last modified: 09-15-2016 04:19 AM by Zervox.)
09-15-2016 04:19 AM
Find all posts by this user Quote this message in a reply
Post Reply