title: iPhone:Accessing documents directory file path in Safari
body: <p>I have placed a file programmatically in documents folder on iPhone like below.</p>
  
  <pre><code>NSFileManager *fileManager = [NSFileManager defaultManager];
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  
  NSError *error;
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"myfilename.xxxxx"];
  
  
  NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"myfilename.xxxxx"];
  BOOL success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&amp;error];
  if (!success) {
      NSAssert1(0, @”Failed to create writable database file with message ‘%@’.”, [error localizedDescription]);
  }
  </code></pre>
  
  <p>I want to access this file in Safari by giving the path of local file through the below code.</p>
  
  <pre><code>[[UIApplication sharedApplication] openURL:[NSURL URLWithString:localFileURL] ];
  </code></pre>
  
  <p>Is it possible? I saw somewhere, we can use the URL starting with "file:///" . Is it true? If yes, how can i access my documents directory file path in Safari passing the URL via the above one line code?</p>
  
  <p>Please advise.</p>
  
  <p>Thank you!</p>