Search code examples
androidtitaniumtitanium-mobile

Where to place pdf file in ti


I recently asked a question relating to how to open a pdf file with a button in android development. Sorry for the vague question, but I will try to make this a little more specific. so I already have this code:

try {
    var f = Ti.Filesystem.getFile('your.pdf');
    Ti.Android.currentActivity.startActivity(Ti.Android.createIntent({
    action: Ti.Android.ACTION_VIEW,
    type: 'application/pdf',
    data: f.getNativePath()
}));
catch (err) {
    var alertDialog = Titanium.UI.createAlertDialog({
    title: //your text,
    message: // your text if not found,
    buttonNames: ['Yes','No'],
    cancel: 1
});
    alertDialog.show();
alertDialog.addEventListener('click', function(evt) {
    if (evt.index == 0) {
    Ti.Platform.openURL('http://search?q=pdf');
}

});

However, I do not know where to place the "Your.pdf file". I tried the assets folder and I typed in

var f = Ti.Filesystem.getFile('assets/your.pdf');

However, I get an error that says 'Invalid character constant'

Help? I hope this question was a little more precise.


Solution

  • We generally place all of our loadable assets under resources, and use the relative paths from the resource folder.