-
-
Save jeffatstepup/3799012 to your computer and use it in GitHub Desktop.
Revisions
-
benbahrenburg created this gist
Dec 23, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ function privateDocumentsDirectory(){ Ti.API.info('We need to open a file object to get our directory info'); var testFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory); Ti.API.info('Now we remove the Documents folder reference'); var privateDir = testFile.nativePath.replace('Documents/',''); Ti.API.info('This is our base App Directory =' + privateDir); Ti.API.info('Now we add the Private Documents Directory'); privateDir+='Library/Private%20Documents/'; Ti.API.info('Our new path is ' + privateDir); return privateDir; }; var myDbName = 'foo123'; Ti.API.info('We create a db to test our method') var testDb = Ti.Database.open(myDbName); var testNativePath = testDb.getFile().nativePath; Ti.API.info('Our nativePath to test against is ' + testNativePath + ' this is what we need to end up with'); var privateDocFolder = privateDocumentsDirectory(); Ti.API.info('Our Private Document Folde is ' + privateDocFolder); Ti.API.info("Let's see if we can find our database"); var dbCheck = Ti.Filesystem.getFile(privateDocFolder, myDbName+ '.sql'); Ti.API.info('Did we find it? ' + dbCheck.exists()); Ti.API.info('Do our file paths match? ' + (dbCheck.nativePath==testNativePath)); Ti.API.info('Example Finished');